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

Unified Diff: ui/file_manager/file_manager/background/js/file_operation_util.js

Issue 2923163002: [abandoned] Remove the destination file after CopyTask cancelation. (Closed)
Patch Set: Resolve review comments. 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: ui/file_manager/file_manager/background/js/file_operation_util.js
diff --git a/ui/file_manager/file_manager/background/js/file_operation_util.js b/ui/file_manager/file_manager/background/js/file_operation_util.js
index 19ba98c21523cfd5e94b30f352045a232b4bcd2a..f73b6b0219d80357ecd3728bd5cbdf26ee2d8644 100644
--- a/ui/file_manager/file_manager/background/js/file_operation_util.js
+++ b/ui/file_manager/file_manager/background/js/file_operation_util.js
@@ -350,6 +350,22 @@ fileOperationUtil.copyTo = function(
source, parent, newName, entryChangedCallback, progressCallback,
successCallback, errorCallback) {
+ var removeDestinationFile = function(callback) {
+ if (source.isFile) {
+ parent.getFile(newName, {}, function(entry) {
+ entry.remove(function() {
+ callback(null);
+ }, callback);
+ }, callback);
+ } else {
+ parent.getDirectory(newName, {}, function(entry) {
+ entry.removeRecursively(function() {
+ callback(null);
+ }, callback);
+ }, callback);
+ }
+ };
+
/** @type {number|undefined} */
var copyId;
var pendingCallbacks = [];
@@ -416,8 +432,18 @@ fileOperationUtil.copyTo = function(
' error: ' + status.error);
chrome.fileManagerPrivate.onCopyProgress.removeListener(
onCopyProgress);
- errorCallback(util.createDOMError(status.error));
- callback();
+ if (status.error === 'AbortError') {
+ removeDestinationFile(function(error) {
+ if (error) {
+ console.error('failed to remove destination file: ' + error);
+ }
+ errorCallback(util.createDOMError(status.error));
+ callback();
+ }.bind(this));
+ } else {
+ errorCallback(util.createDOMError(status.error));
+ callback();
+ }
break;
default:
« 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