Use synchronous object getters during sync
Since objects should always already be loaded
This commit is contained in:
parent
f751495ce8
commit
f8a0f9ad1d
2 changed files with 7 additions and 13 deletions
|
@ -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
|
* @param {Boolean} [options.noCache=false] - Don't add object to cache after loading
|
||||||
* @return {Promise<Zotero.DataObject>} - Promise for a data object, or FALSE if not found
|
* @return {Promise<Zotero.DataObject>} - 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);
|
var id = this.getIDFromLibraryAndKey(libraryID, key);
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -294,9 +294,7 @@ Zotero.Sync.Data.Engine.prototype._startDownload = Zotero.Promise.coroutine(func
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let obj = yield objectsClass.getByLibraryAndKeyAsync(
|
let obj = objectsClass.getByLibraryAndKey(this.libraryID, key);
|
||||||
this.libraryID, key, { noCache: true }
|
|
||||||
);
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -338,8 +336,8 @@ Zotero.Sync.Data.Engine.prototype._startDownload = Zotero.Promise.coroutine(func
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(function* () {
|
||||||
for (let json of chunk) {
|
for (let json of chunk) {
|
||||||
if (!json.deleted) continue;
|
if (!json.deleted) continue;
|
||||||
let obj = yield objectsClass.getByLibraryAndKeyAsync(
|
let obj = objectsClass.getByLibraryAndKey(
|
||||||
this.libraryID, json.key, { noCache: true }
|
this.libraryID, json.key
|
||||||
);
|
);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
Zotero.logError("Remotely deleted " + objectType
|
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 + ")");
|
throw new Error("Key mismatch (" + key + " != " + batch[index].key + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
let obj = yield objectsClass.getByLibraryAndKeyAsync(
|
let obj = objectsClass.getByLibraryAndKey(this.libraryID, key);
|
||||||
this.libraryID, key, { noCache: true }
|
|
||||||
)
|
|
||||||
ids.push(obj.id);
|
ids.push(obj.id);
|
||||||
|
|
||||||
if (state == 'successful') {
|
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) {
|
Zotero.Sync.Data.Engine.prototype._getJSONForObject = function (objectType, id) {
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
return Zotero.DB.executeTransaction(function* () {
|
||||||
var objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
var objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
||||||
var obj = yield objectsClass.getAsync(id, { noCache: true });
|
var obj = objectsClass.get(id);
|
||||||
var cacheObj = false;
|
var cacheObj = false;
|
||||||
if (obj.version) {
|
if (obj.version) {
|
||||||
cacheObj = yield Zotero.Sync.Data.Local.getCacheObject(
|
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
|
// Queue objects that are out of date or don't exist locally
|
||||||
for (let key in results.versions) {
|
for (let key in results.versions) {
|
||||||
let version = results.versions[key];
|
let version = results.versions[key];
|
||||||
let obj = yield objectsClass.getByLibraryAndKeyAsync(this.libraryID, key, {
|
let obj = objectsClass.getByLibraryAndKey(this.libraryID, key);
|
||||||
noCache: true
|
|
||||||
});
|
|
||||||
// If object already at latest version, skip
|
// If object already at latest version, skip
|
||||||
let localVersion = localVersions[key];
|
let localVersion = localVersions[key];
|
||||||
if (localVersion && localVersion === version) {
|
if (localVersion && localVersion === version) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue