Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Unified Diff: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc

Issue 2918273002: [abandoned] Remove the destination file after failed copy. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc
index cfdd9e3bdb58c7675d4c6b45b31fd338cbeb8bd8..bde8520b526e5ba290971d9cb8540cec1ebab29f 100644
--- a/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/private_api_file_system.cc
@@ -159,16 +159,30 @@ void NotifyCopyCompletion(
source_url.ToGURL(), destination_url.ToGURL(), error);
}
+void OnRemoveAfterFailedCopyCompleted(base::File::Error error) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ // We just ignore the status.
+ DLOG_IF(WARNING, error != base::File::FILE_OK)
+ << "Failed to remove the destination file after failed copy: " << error;
+}
+
// Callback invoked upon completion of Copy() (regardless of succeeded or
// failed).
void OnCopyCompleted(
void* profile_id,
+ scoped_refptr<storage::FileSystemContext> file_system_context,
storage::FileSystemOperationRunner::OperationID* operation_id,
const FileSystemURL& source_url,
const FileSystemURL& destination_url,
base::File::Error error) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (error != base::File::FILE_OK) {
+ file_system_context->operation_runner()->Remove(
+ destination_url, false, base::Bind(&OnRemoveAfterFailedCopyCompleted));
fukino 2017/06/05 04:20:08 Is it safe to call NotifyCopyCompletion before Rem
+ }
+
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&NotifyCopyCompletion, profile_id, *operation_id,
@@ -197,8 +211,8 @@ storage::FileSystemOperationRunner::OperationID StartCopyOnIOThread(
storage::FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED,
storage::FileSystemOperation::ERROR_BEHAVIOR_ABORT,
base::Bind(&OnCopyProgress, profile_id, base::Unretained(operation_id)),
- base::Bind(&OnCopyCompleted, profile_id, base::Owned(operation_id),
- source_url, destination_url));
+ base::Bind(&OnCopyCompleted, profile_id, file_system_context,
+ base::Owned(operation_id), source_url, destination_url));
return *operation_id;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698