Allow higher local object version during full sync

Local object versions can be higher than remote versions, because we
upload in batches and only record the version from the last batch.

This could cause trouble if an object failed to upload during a Restore
to Online Library, causing it to be retried later with version 0 (unlike
during a restore when the version is omitted), causing the library to be
reset, causing any local objects with higher local versions to be
redownloaded.
This commit is contained in:
Dan Stillman 2018-04-14 16:40:36 -04:00
parent 794d3880e7
commit 8853f8ca47

View file

@ -1691,22 +1691,14 @@ Zotero.Sync.Data.Engine.prototype._fullSync = Zotero.Promise.coroutine(function*
for (let key in results.versions) {
let version = results.versions[key];
let obj = objectsClass.getByLibraryAndKey(this.libraryID, key);
// If object already at latest version, skip
// If object is already at or above latest version, skip. Local version can be
// higher because, as explained in _uploadObjects(), we upload items in batches
// and only get the last version to record in the database.
let localVersion = localVersions[key];
if (localVersion && localVersion === version) {
if (localVersion && localVersion >= version) {
continue;
}
// This should never happen
if (localVersion > version) {
Zotero.logError(`Local version of ${objectType} ${this.libraryID}/${key} `
+ `is later than remote! (${localVersion} > ${version})`);
// Delete cache version if it's there
yield Zotero.Sync.Data.Local.deleteCacheObjectVersions(
objectType, this.libraryID, key, localVersion, localVersion
);
}
if (obj) {
Zotero.debug(`${ObjectType} ${obj.libraryKey} is older than remote version`);
}