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

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

Issue 1016613005: Files.app: Avoid triggering spurious errors on cloud import cancellation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/media_import_handler.js
diff --git a/ui/file_manager/file_manager/background/js/media_import_handler.js b/ui/file_manager/file_manager/background/js/media_import_handler.js
index a796cf5034723b492522690d61d4437b372a999c..6b04b756de7c97cd09632c3b5b00c239999a6df1 100644
--- a/ui/file_manager/file_manager/background/js/media_import_handler.js
+++ b/ui/file_manager/file_manager/background/js/media_import_handler.js
@@ -317,8 +317,9 @@ importer.MediaImportHandler.ImportTask.prototype.importOne_ =
/**
* @param {!FileEntry} entry The file to copy.
* @param {!DirectoryEntry} destinationDirectory The destination directory.
- * @return {!Promise<!FileEntry>} Resolves to the destination file when the copy
- * is complete.
+ * @return {!Promise<FileEntry>} Resolves to the destination file when the copy
+ * is complete. The FileEntry may be null if the import was cancelled. The
+ * promise will reject if an error occurs.
* @private
*/
importer.MediaImportHandler.ImportTask.prototype.copy_ =
@@ -375,13 +376,20 @@ importer.MediaImportHandler.ImportTask.prototype.copy_ =
/** @this {importer.MediaImportHandler.ImportTask} */
var onError = function(error) {
this.cancelCallback_ = null;
- this.errorCount_++;
// Log the bytes as processed in spite of the error. This ensures
// completion of the progress bar.
this.processedBytes_ -= currentBytes;
this.processedBytes_ += entry.size;
- this.notify(importer.TaskQueue.UpdateType.ERROR);
- resolver.reject(error);
+ if (error.name === util.FileError.ABORT_ERR) {
+ // Task cancellations result in the error callback being triggered with an
+ // ABORT_ERR, but we want to ignore these errors.
+ this.notify(importer.TaskQueue.UpdateType.PROGRESS);
+ resolver.resolve(null);
+ } else {
+ this.errorCount_++;
+ this.notify(importer.TaskQueue.UpdateType.ERROR);
+ resolver.reject(error);
+ }
};
fileOperationUtil.deduplicatePath(destinationDirectory, entry.name)
« 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