commit 277086096808cfd4f2cd3effd2e4f825f72a8065
parent 906955905068f2de45966aecb0d070daaf1cc490
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 11 Aug 2017 20:29:32 +0200
Don't update storage version if file sync is stopped
Otherwise subsequent syncs won't download the remaining files until
there's a remote storage change.
Diffstat:
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/storage/storageEngine.js b/chrome/content/zotero/xpcom/storage/storageEngine.js
@@ -222,7 +222,7 @@ Zotero.Sync.Storage.Engine.prototype.start = Zotero.Promise.coroutine(function*
if (p.isFulfilled()) {
succeeded++;
}
- else {
+ else if (!p.isPending()) {
if (this.stopOnError) {
let e = p.reason();
Zotero.debug(`File ${type} sync failed for ${this.library.name}`);
@@ -237,7 +237,11 @@ Zotero.Sync.Storage.Engine.prototype.start = Zotero.Promise.coroutine(function*
changes.updateFromResults(results.filter(p => p.isFulfilled()).map(p => p.value()));
- if (type == 'download' && results.every(p => !p.isRejected())) {
+ if (type == 'download'
+ // Not stopped
+ && this.requestsRemaining == 0
+ // No errors
+ && results.every(p => !p.isRejected())) {
downloadSuccessful = true;
}
}
diff --git a/test/tests/zfsTest.js b/test/tests/zfsTest.js
@@ -164,6 +164,40 @@ describe("Zotero.Sync.Storage.Mode.ZFS", function () {
assert.equal(library.storageVersion, library.libraryVersion);
})
+ it("shouldn't update storageVersion if stopped", function* () {
+ var { engine, client, caller } = yield setup();
+
+ var library = Zotero.Libraries.userLibrary;
+ library.libraryVersion = 5;
+ yield library.saveTx();
+ library.storageDownloadNeeded = true;
+
+ var items = [];
+ for (let i = 0; i < 5; i++) {
+ let item = new Zotero.Item("attachment");
+ item.attachmentLinkMode = 'imported_file';
+ item.attachmentPath = 'storage:test.txt';
+ item.attachmentSyncState = "to_download";
+ yield item.saveTx();
+ items.push(item);
+ }
+
+ var call = 0;
+ var stub = sinon.stub(engine.controller, 'downloadFile').callsFake(function () {
+ call++;
+ if (call == 1) {
+ engine.stop();
+ }
+ return new Zotero.Sync.Storage.Result;
+ });
+
+ var result = yield engine.start();
+
+ stub.restore();
+
+ assert.equal(library.storageVersion, 0);
+ });
+
it("should handle a remotely failing file", function* () {
var { engine, client, caller } = yield setup();