commit f844d9e46d85c5c502df1e22e7a6caea8caa76cc
parent e0e744f9b14db876b50e9cec13b74f9908eca782
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 3 May 2016 01:16:05 -0400
Skip full-text content download if main library version hasn't changed
Since a data sync always happens first, the main library version will
always be higher if there's any full-text content to download.
Diffstat:
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/sync/syncFullTextEngine.js b/chrome/content/zotero/xpcom/sync/syncFullTextEngine.js
@@ -53,7 +53,13 @@ Zotero.Sync.Data.FullTextEngine.prototype.start = Zotero.Promise.coroutine(funct
// Get last full-text version in settings
var libraryVersion = yield Zotero.FullText.getLibraryVersion(this.libraryID);
- yield this._download(libraryVersion);
+ // If main library version has changed, check to see if there's no full-text content
+ if (this.library.libraryVersion > libraryVersion) {
+ yield this._download(libraryVersion);
+ }
+ else {
+ Zotero.debug("Library version hasn't changed -- skipping full-text download");
+ }
yield this._upload();
})
diff --git a/test/tests/syncFullTextEngineTest.js b/test/tests/syncFullTextEngineTest.js
@@ -59,6 +59,15 @@ describe("Zotero.Sync.Data.FullTextEngine", function () {
})
describe("Full-Text Syncing", function () {
+ it("should skip full-text download if main library version is the same", function* () {
+ ({ engine, client, caller } = yield setup());
+ var library = Zotero.Libraries.userLibrary;
+ library.libraryVersion = 10;
+ yield library.saveTx();
+ yield Zotero.Fulltext.setLibraryVersion(library.id, 10);
+ yield engine.start();
+ });
+
it("should download full-text into a new library and subsequent updates", function* () {
({ engine, client, caller } = yield setup());
@@ -75,6 +84,12 @@ describe("Zotero.Sync.Data.FullTextEngine", function () {
var itemFullTextVersion = 10;
var libraryVersion = 15;
+
+ // Set main library version to new version
+ var library = Zotero.Libraries.userLibrary;
+ library.libraryVersion = libraryVersion;
+ yield library.saveTx();
+
setResponse({
method: "GET",
url: "users/1/fulltext?format=versions",
@@ -136,6 +151,11 @@ describe("Zotero.Sync.Data.FullTextEngine", function () {
itemFullTextVersion = 17;
var lastLibraryVersion = libraryVersion;
libraryVersion = 20;
+
+ // Set main library version to new version
+ library.libraryVersion = libraryVersion;
+ yield library.saveTx();
+
setResponse({
method: "GET",
url: "users/1/fulltext?format=versions&since=" + lastLibraryVersion,