Don't trigger 'redraw' event on attachment download 404

There's no need to refresh the attachments column of the item row if
nothing was downloaded.

Also remove some unnecessary logging
This commit is contained in:
Dan Stillman 2021-06-03 23:39:14 -04:00
parent a5fe49b866
commit 07eda894f3
2 changed files with 15 additions and 4 deletions

View file

@ -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) {

View file

@ -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;
}