From f8a0f9ad1d0e8ac8bdf0f1d5cf1927e7c2f94bcf Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 3 May 2016 17:37:05 -0400 Subject: [PATCH] Use synchronous object getters during sync Since objects should always already be loaded --- .../content/zotero/xpcom/data/dataObjects.js | 2 +- chrome/content/zotero/xpcom/sync/syncEngine.js | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js index 2c33be246..0274e0b67 100644 --- a/chrome/content/zotero/xpcom/data/dataObjects.js +++ b/chrome/content/zotero/xpcom/data/dataObjects.js @@ -281,7 +281,7 @@ Zotero.DataObjects.prototype.getByLibraryAndKey = function (libraryID, key, opti * @param {Boolean} [options.noCache=false] - Don't add object to cache after loading * @return {Promise} - Promise for a data object, or FALSE if not found */ -Zotero.DataObjects.prototype.getByLibraryAndKeyAsync = Zotero.Promise.coroutine(function* (libraryID, key, options) { +Zotero.DataObjects.prototype.getByLibraryAndKeyAsync = Zotero.Promise.method(function (libraryID, key, options) { var id = this.getIDFromLibraryAndKey(libraryID, key); if (!id) { return false; diff --git a/chrome/content/zotero/xpcom/sync/syncEngine.js b/chrome/content/zotero/xpcom/sync/syncEngine.js index 66565f6cf..b8cae9e02 100644 --- a/chrome/content/zotero/xpcom/sync/syncEngine.js +++ b/chrome/content/zotero/xpcom/sync/syncEngine.js @@ -294,9 +294,7 @@ Zotero.Sync.Data.Engine.prototype._startDownload = Zotero.Promise.coroutine(func continue; } - let obj = yield objectsClass.getByLibraryAndKeyAsync( - this.libraryID, key, { noCache: true } - ); + let obj = objectsClass.getByLibraryAndKey(this.libraryID, key); if (!obj) { continue; } @@ -338,8 +336,8 @@ Zotero.Sync.Data.Engine.prototype._startDownload = Zotero.Promise.coroutine(func return Zotero.DB.executeTransaction(function* () { for (let json of chunk) { if (!json.deleted) continue; - let obj = yield objectsClass.getByLibraryAndKeyAsync( - this.libraryID, json.key, { noCache: true } + let obj = objectsClass.getByLibraryAndKey( + this.libraryID, json.key ); if (!obj) { Zotero.logError("Remotely deleted " + objectType @@ -865,9 +863,7 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func throw new Error("Key mismatch (" + key + " != " + batch[index].key + ")"); } - let obj = yield objectsClass.getByLibraryAndKeyAsync( - this.libraryID, key, { noCache: true } - ) + let obj = objectsClass.getByLibraryAndKey(this.libraryID, key); ids.push(obj.id); if (state == 'successful') { @@ -1027,7 +1023,7 @@ Zotero.Sync.Data.Engine.prototype._uploadDeletions = Zotero.Promise.coroutine(fu Zotero.Sync.Data.Engine.prototype._getJSONForObject = function (objectType, id) { return Zotero.DB.executeTransaction(function* () { var objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType); - var obj = yield objectsClass.getAsync(id, { noCache: true }); + var obj = objectsClass.get(id); var cacheObj = false; if (obj.version) { cacheObj = yield Zotero.Sync.Data.Local.getCacheObject( @@ -1284,9 +1280,7 @@ Zotero.Sync.Data.Engine.prototype._fullSync = Zotero.Promise.coroutine(function* // Queue objects that are out of date or don't exist locally for (let key in results.versions) { let version = results.versions[key]; - let obj = yield objectsClass.getByLibraryAndKeyAsync(this.libraryID, key, { - noCache: true - }); + let obj = objectsClass.getByLibraryAndKey(this.libraryID, key); // If object already at latest version, skip let localVersion = localVersions[key]; if (localVersion && localVersion === version) {