Index: webkit/browser/fileapi/copy_or_move_operation_delegate.cc |
diff --git a/webkit/browser/fileapi/copy_or_move_operation_delegate.cc b/webkit/browser/fileapi/copy_or_move_operation_delegate.cc |
index 97de4f406df6fe1a257951d76af1ec3c2bfc2ccd..27a03d5725015bc6af9599ea814742a362545b0d 100644 |
--- a/webkit/browser/fileapi/copy_or_move_operation_delegate.cc |
+++ b/webkit/browser/fileapi/copy_or_move_operation_delegate.cc |
@@ -423,10 +423,12 @@ class StreamCopyOrMoveImpl |
// To use FileStreamWriter, we need to ensure the destination file exists. |
operation_runner_->CreateFile( |
- dest_url_, false /* exclusive */, |
+ dest_url_, |
+ true /* exclusive */, |
base::Bind(&StreamCopyOrMoveImpl::RunAfterCreateFileForDestination, |
weak_factory_.GetWeakPtr(), |
- callback, file_info.last_modified)); |
+ callback, |
+ file_info.last_modified)); |
} |
void RunAfterCreateFileForDestination( |
@@ -436,6 +438,31 @@ class StreamCopyOrMoveImpl |
if (cancel_requested_) |
error = base::File::FILE_ERROR_ABORT; |
+ if (error != base::File::FILE_OK && |
+ error != base::File::FILE_ERROR_EXISTS) { |
+ callback.Run(error); |
+ return; |
+ } |
+ |
+ if (error == base::File::FILE_ERROR_EXISTS) { |
+ operation_runner_->Truncate( |
+ dest_url_, |
+ 0 /* length */, |
+ base::Bind(&StreamCopyOrMoveImpl::RunAfterTruncateForDestination, |
+ weak_factory_.GetWeakPtr(), |
+ callback, |
+ last_modified)); |
+ return; |
+ } |
tzik
2014/09/03 02:07:43
error == FILE_OK case handling?
iseki
2014/09/03 03:28:21
Done.
|
+ } |
+ |
+ void RunAfterTruncateForDestination( |
+ const CopyOrMoveOperationDelegate::StatusCallback& callback, |
+ const base::Time& last_modified, |
+ base::File::Error error) { |
+ if (cancel_requested_) |
+ error = base::File::FILE_ERROR_ABORT; |
+ |
if (error != base::File::FILE_OK) { |
callback.Run(error); |
return; |