From 8853f8ca47802dfed6d7fff24965e447b988bbf8 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 14 Apr 2018 16:40:36 -0400 Subject: [PATCH] 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. --- chrome/content/zotero/xpcom/sync/syncEngine.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/chrome/content/zotero/xpcom/sync/syncEngine.js b/chrome/content/zotero/xpcom/sync/syncEngine.js index b61661fba0..455e95d67f 100644 --- a/chrome/content/zotero/xpcom/sync/syncEngine.js +++ b/chrome/content/zotero/xpcom/sync/syncEngine.js @@ -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`); }