diff --git a/chrome/content/zotero/xpcom/sync/syncFullTextEngine.js b/chrome/content/zotero/xpcom/sync/syncFullTextEngine.js index 16b68b7eab..23cc98dfcb 100644 --- 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 index 593058b829..66f5a9b90c 100644 --- 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,