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.
This commit is contained in:
parent
e0e744f9b1
commit
f844d9e46d
2 changed files with 27 additions and 1 deletions
|
@ -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);
|
||||
// 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();
|
||||
})
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue