diff --git a/chrome/content/zotero/xpcom/storage/storageRequest.js b/chrome/content/zotero/xpcom/storage/storageRequest.js index f1b0a6ae80..d3d15eb468 100644 --- a/chrome/content/zotero/xpcom/storage/storageRequest.js +++ b/chrome/content/zotero/xpcom/storage/storageRequest.js @@ -56,6 +56,7 @@ Zotero.Sync.Storage.Request = function (options) { this._deferred = Zotero.Promise.defer(); this._running = false; this._stopping = false; + this._progressUpdated = false; this._percentage = 0; this._remaining = null; this._maxSize = null; @@ -199,7 +200,6 @@ Zotero.Sync.Storage.Request.prototype.start = Zotero.Promise.coroutine(function* result.updateFromResults(results); Zotero.debug(this.Type + " request " + this.name + " finished"); - Zotero.debug(result + ""); return result; } @@ -211,7 +211,11 @@ Zotero.Sync.Storage.Request.prototype.start = Zotero.Promise.coroutine(function* this._finished = true; this._running = false; - Zotero.Sync.Storage.setItemDownloadPercentage(this.name, false); + // Clear the progress bar if it was set previously or we were told not to + // (e.g., by zfs.js on a 404) + if (this._progressUpdated || !this.skipProgressBarUpdate) { + Zotero.Sync.Storage.setItemDownloadPercentage(this.name, false); + } if (this._onStop) { this._onStop.forEach(x => x()); @@ -258,7 +262,7 @@ Zotero.Sync.Storage.Request.prototype.onProgress = function (progress, progressM return; } - if (progressMax != this.progressMax) { + if (this.progressMax && progressMax != this.progressMax) { Zotero.debug("progressMax has changed from " + this.progressMax + " to " + progressMax + " for request '" + this.name + "'", 2); } @@ -267,7 +271,12 @@ Zotero.Sync.Storage.Request.prototype.onProgress = function (progress, progressM this.progressMax = progressMax; if (this.type == 'download') { - Zotero.Sync.Storage.setItemDownloadPercentage(this.name, this.percentage); + // Update progress bar if we didn't skip to 100 on the first step (which might indicate a + // request failure) + if (this._progressUpdated || progress != progressMax) { + Zotero.Sync.Storage.setItemDownloadPercentage(this.name, this.percentage); + this._progressUpdated = true; + } } if (this._onProgress) { diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js index 511f020578..19fd1212f5 100644 --- a/chrome/content/zotero/xpcom/storage/zfs.js +++ b/chrome/content/zotero/xpcom/storage/zfs.js @@ -154,6 +154,8 @@ Zotero.Sync.Storage.Mode.ZFS.prototype = { if (status != 200) { if (status == 404) { Zotero.debug("Remote file not found for item " + item.libraryKey); + // Don't refresh item pane rows when nothing happened + request.skipProgressBarUpdate = true; deferred.resolve(new Zotero.Sync.Storage.Result); return; }