commit 4c13d51f24cd0504aab2f82b3cc3cec3a0458747
parent 0df967418b6f4df6e6224d335dc6e1cea12017da
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 10 Aug 2017 22:41:27 +0200
Show files remaining in library in sync button tooltip
Diffstat:
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/chrome/content/zotero/xpcom/storage/storageEngine.js b/chrome/content/zotero/xpcom/storage/storageEngine.js
@@ -34,6 +34,7 @@ if (!Zotero.Sync.Storage) {
* @param {Object} options
* @param {Integer} options.libraryID
* @param {Object} options.controller - Storage controller instance (ZFS_Controller/WebDAV_Controller)
+ * @param {Function} [onProgress] - Function to run when a request finishes: f(progress, progressMax)
* @param {Function} [onError] - Function to run on error
* @param {Boolean} [stopOnError]
*/
@@ -52,11 +53,15 @@ Zotero.Sync.Storage.Engine = function (options) {
this.library = Zotero.Libraries.get(options.libraryID);
this.controller = options.controller;
+ this.numRequests = 0;
+ this.requestsRemaining = 0;
+
this.local = Zotero.Sync.Storage.Local;
this.utils = Zotero.Sync.Storage.Utilities;
this.setStatus = options.setStatus || function () {};
this.onError = options.onError || function (e) {};
+ this.onProgress = options.onProgress || function (progress, progressMax) {};
this.stopOnError = options.stopOnError || false;
this.queues = [];
@@ -136,6 +141,7 @@ Zotero.Sync.Storage.Engine.prototype.start = Zotero.Promise.coroutine(function*
}
var filesEditable = Zotero.Libraries.get(libraryID).filesEditable;
+ this.requestsRemaining = 0;
// Check for updated files to upload
if (!filesEditable) {
@@ -322,8 +328,13 @@ Zotero.Sync.Storage.Engine.prototype.queueItem = Zotero.Promise.coroutine(functi
libraryID: this.libraryID,
name: item.libraryKey,
onStart: request => this.controller[fn](request),
- onProgress: this.onProgress
+ onStop: () => {
+ this.requestsRemaining--;
+ this.onProgress(this.numRequests - this.requestsRemaining, this.numRequests);
+ }
});
return request.start();
});
+ this.numRequests++;
+ this.requestsRemaining++;
})
diff --git a/chrome/content/zotero/xpcom/sync/syncRunner.js b/chrome/content/zotero/xpcom/sync/syncRunner.js
@@ -609,12 +609,27 @@ Zotero.Sync.Runner_Module = function (options = {}) {
*/
var _doFileSync = Zotero.Promise.coroutine(function* (libraries, options) {
Zotero.debug("Starting file syncing");
- this.setSyncStatus(Zotero.getString('sync.status.syncingFiles'));
var resyncLibraries = []
for (let libraryID of libraries) {
_stopCheck();
+ this.setSyncStatus(
+ Zotero.getString(
+ 'sync.status.syncingFilesInLibrary', Zotero.Libraries.get(libraryID).name
+ )
+ );
try {
- let opts = {};
+ let opts = {
+ onProgress: (progress, progressMax) => {
+ var remaining = progressMax - progress;
+ this.setSyncStatus(
+ Zotero.getString(
+ 'sync.status.syncingFilesInLibraryWithRemaining',
+ [Zotero.Libraries.get(libraryID).name, remaining],
+ remaining
+ )
+ );
+ }
+ };
Object.assign(opts, options);
opts.libraryID = libraryID;
diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties
@@ -967,6 +967,8 @@ sync.status.processingUpdatedData = Processing updated data from sync server
sync.status.uploadingData = Uploading data to sync server
sync.status.uploadAccepted = Upload accepted \u2014 waiting for sync server
sync.status.syncingFiles = Syncing files
+sync.status.syncingFilesInLibrary = Syncing files in %S
+sync.status.syncingFilesInLibraryWithRemaining = Syncing files in %1$S (%2$S remaining);Syncing files in %1$S (%2$S remaining)
sync.status.syncingFullText = Syncing full-text content
sync.storage.mbRemaining = %SMB remaining