From a207e388db28c5c51091283403eafe946887de36 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 10 May 2017 22:48:03 -0400 Subject: [PATCH] Fix attachment download progress pies --- chrome/content/zotero/xpcom/storage.js | 4 ++++ chrome/content/zotero/xpcom/storage/storageRequest.js | 4 +++- chrome/content/zotero/xpcom/storage/streamListener.js | 2 +- chrome/content/zotero/xpcom/storage/zfs.js | 4 ++-- chrome/content/zotero/zoteroPane.js | 7 +------ 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index aa0d01e61..a7518371a 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -97,6 +97,10 @@ Zotero.Sync.Storage = new function () { } + /** + * @param {String} libraryKey + * @param {Number|NULL} + */ this.setItemDownloadPercentage = function (libraryKey, percentage) { Zotero.debug("Setting image download percentage to " + percentage + " for item " + libraryKey); diff --git a/chrome/content/zotero/xpcom/storage/storageRequest.js b/chrome/content/zotero/xpcom/storage/storageRequest.js index 739ffbbb2..fbbb7ebba 100644 --- a/chrome/content/zotero/xpcom/storage/storageRequest.js +++ b/chrome/content/zotero/xpcom/storage/storageRequest.js @@ -209,6 +209,8 @@ Zotero.Sync.Storage.Request.prototype.start = Zotero.Promise.coroutine(function* this._finished = true; this._running = false; + Zotero.Sync.Storage.setItemDownloadPercentage(this.name, false); + if (this._onStop) { this._onStop.forEach(x => x()); } @@ -266,7 +268,7 @@ Zotero.Sync.Storage.Request.prototype.onProgress = function (progress, progressM Zotero.Sync.Storage.setItemDownloadPercentage(this.name, this.percentage); } - if (this.onProgress && this._onProgress) { + if (this._onProgress) { for (let f of this._onProgress) { f(progress, progressMax); } diff --git a/chrome/content/zotero/xpcom/storage/streamListener.js b/chrome/content/zotero/xpcom/storage/streamListener.js index b62b7c7c6..7e0790382 100644 --- a/chrome/content/zotero/xpcom/storage/streamListener.js +++ b/chrome/content/zotero/xpcom/storage/streamListener.js @@ -102,7 +102,7 @@ Zotero.Sync.Storage.StreamListener.prototype = { // nsIWebProgressListener onProgressChange: function (wp, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) { - Zotero.debug("onProgressChange with " + curTotalProgress + "/" + maxTotalProgress); + //Zotero.debug("onProgressChange with " + curTotalProgress + "/" + maxTotalProgress); // onProgress gets called too, so this isn't necessary //this._onProgress(request, curTotalProgress, maxTotalProgress); diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js index 8abaf92bb..15d3af8be 100644 --- a/chrome/content/zotero/xpcom/storage/zfs.js +++ b/chrome/content/zotero/xpcom/storage/zfs.js @@ -145,8 +145,8 @@ Zotero.Sync.Storage.Mode.ZFS.prototype = { return false; }), - onProgress: function (a, b, c) { - request.onProgress(a, b, c) + onProgress: function (req, progress, progressMax) { + request.onProgress(progress, progressMax); }, onStop: function (req, status, res) { request.setChannel(false); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 2365aa685..c3954cde5 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -4119,12 +4119,7 @@ var ZoteroPane = new function() let downloadedItem = item; try { - yield Zotero.Sync.Runner.downloadFile( - downloadedItem, - { - onProgress: function (progress, progressMax) {} - } - ); + yield Zotero.Sync.Runner.downloadFile(downloadedItem); } catch (e) { // TODO: show error somewhere else