commit cbed716424acca3552acf9fc36aa3a616a57fac4
parent ddb7d3107d1c1c2a302f36820c098a74e09ac5a2
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 16 Feb 2017 17:59:30 -0500
Fix format of object data added back to upload queue after failure
Diffstat:
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/chrome/content/zotero/xpcom/sync/syncEngine.js b/chrome/content/zotero/xpcom/sync/syncEngine.js
@@ -1000,7 +1000,7 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func
}
);
}
- batch.push(o.json);
+ batch.push(o);
}
// No more non-failed requests
@@ -1011,8 +1011,10 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func
// Remove selected and skipped objects from queue
queue.splice(0, batch.length + numSkipped);
+ let jsonBatch = batch.map(o => o.json);
+
Zotero.debug("UPLOAD BATCH:");
- Zotero.debug(batch);
+ Zotero.debug(jsonBatch);
let results;
let numSuccessful = 0;
@@ -1022,7 +1024,7 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func
"POST",
libraryVersion,
objectType,
- batch
+ jsonBatch
));
// Mark successful and unchanged objects as synced with new version,
@@ -1038,8 +1040,8 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func
let key = state == 'successful' ? current.key : current;
let changed = changedObjects.has(key);
- if (key != batch[index].key) {
- throw new Error("Key mismatch (" + key + " != " + batch[index].key + ")");
+ if (key != jsonBatch[index].key) {
+ throw new Error("Key mismatch (" + key + " != " + jsonBatch[index].key + ")");
}
let obj = objectsClass.getByLibraryAndKey(this.libraryID, key);
@@ -1070,13 +1072,14 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func
// will guarantee that the item won't be redownloaded unnecessarily in the case of
// a full sync, because the version will be higher than whatever version is on the
// server.
- batch[index].version = libraryVersion;
- toCache.push(batch[index]);
+ jsonBatch[index].version = libraryVersion;
+ toCache.push(jsonBatch[index]);
}
numSuccessful++;
// Remove from batch to mark as successful
delete batch[index];
+ delete jsonBatch[index];
}
}
yield Zotero.Sync.Data.Local.saveCacheObjects(
@@ -1107,7 +1110,7 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func
if (data) {
e.data = data;
}
- Zotero.logError("Error for " + objectType + " " + batch[index].key + " in "
+ Zotero.logError("Error for " + objectType + " " + jsonBatch[index].key + " in "
+ this.library.name + ":\n\n" + e);
// This shouldn't happen, because the upload request includes a library version and should