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

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

Issue 2912033002: Continue CopyTask when some files are unreadable. (Closed)
Patch Set: Do not run deleteOriginals when we have lastError. 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..73bb7268651baf18e607a82adb79fbd255e18461 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
@@ -683,6 +683,13 @@ fileOperationUtil.CopyTask = function(
fileOperationUtil.CopyTask.prototype.__proto__ =
fileOperationUtil.Task.prototype;
+/**
+ * Number of consecutive errors to stop CopyTask.
+ * @const {number}
+ * @private
+ */
+fileOperationUtil.CopyTask.CONSECUTIVE_ERROR_LIMIT_ = 100;
+
/**
* Initializes the CopyTask.
* @param {function()} callback Called when the initialize is completed.
@@ -800,6 +807,11 @@ fileOperationUtil.CopyTask.prototype.run = function(
this.updateProgressRateLimiter_ = new AsyncUtil.RateLimiter(progressCallback);
+ // Number of consecutive errors. Increases while failing and resets to zero
+ // when one of them succeeds.
+ var errorCount = 0;
+ var lastError;
+
AsyncUtil.forEach(
this.sourceEntries,
function(callback, entry, index) {
@@ -830,16 +842,29 @@ fileOperationUtil.CopyTask.prototype.run = function(
// Update current source index and processing bytes.
this.processingSourceIndex_ = index + 1;
this.processedBytes = this.calcProcessedBytes_();
+ errorCount = 0;
callback();
}.bind(this),
function(error) {
// Finishes off delayed updates if necessary.
this.updateProgressRateLimiter_.runImmediately();
- errorCallback(error);
+ // Update current source index and processing bytes.
+ this.processingSourceIndex_ = index + 1;
+ this.processedBytes = this.calcProcessedBytes_();
+ errorCount++;
+ lastError = error;
+ if (errorCount <
+ fileOperationUtil.CopyTask.CONSECUTIVE_ERROR_LIMIT_) {
+ callback();
+ } else {
+ errorCallback(error);
+ }
}.bind(this));
},
function() {
- if (this.deleteAfterCopy) {
+ if (lastError) {
+ errorCallback(lastError);
+ } else if (this.deleteAfterCopy) {
deleteOriginals();
} else {
successCallback();
« 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