From e03cf637b6edf4bd0b9906b3aa432234036e4dd9 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 2 Nov 2015 03:20:29 -0500 Subject: [PATCH] Fix 412 handling --- .../content/zotero/xpcom/sync/syncEngine.js | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/chrome/content/zotero/xpcom/sync/syncEngine.js b/chrome/content/zotero/xpcom/sync/syncEngine.js index 424ca3fcae..aedca11492 100644 --- a/chrome/content/zotero/xpcom/sync/syncEngine.js +++ b/chrome/content/zotero/xpcom/sync/syncEngine.js @@ -604,18 +604,26 @@ Zotero.Sync.Data.Engine.prototype._startUpload = Zotero.Promise.coroutine(functi return this.UPLOAD_RESULT_NOTHING_TO_UPLOAD; } - Zotero.debug(JSON.stringify(objectIDs)); - for (let objectType in objectIDs) { - libraryVersion = yield this._uploadObjects( - objectType, objectIDs[objectType], libraryVersion - ); + try { + Zotero.debug(JSON.stringify(objectIDs)); + for (let objectType in objectIDs) { + libraryVersion = yield this._uploadObjects( + objectType, objectIDs[objectType], libraryVersion + ); + } + + Zotero.debug(JSON.stringify(objectDeletions)); + for (let objectType in objectDeletions) { + libraryVersion = yield this._uploadDeletions( + objectType, objectDeletions[objectType], libraryVersion + ); + } } - - Zotero.debug(JSON.stringify(objectDeletions)); - for (let objectType in objectDeletions) { - libraryVersion = yield this._uploadDeletions( - objectType, objectDeletions[objectType], libraryVersion - ); + catch (e) { + if (e instanceof Zotero.HTTP.UnexpectedStatusException && e.status == 412) { + return this.UPLOAD_RESULT_LIBRARY_CONFLICT; + } + throw e; } return this.UPLOAD_RESULT_SUCCESS; @@ -776,7 +784,7 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func catch (e) { if (e instanceof Zotero.HTTP.UnexpectedStatusException) { if (e.status == 412) { - return this.UPLOAD_RESULT_LIBRARY_CONFLICT; + throw e; } // On 5xx, delay and retry @@ -838,7 +846,7 @@ Zotero.Sync.Data.Engine.prototype._uploadDeletions = Zotero.Promise.coroutine(fu catch (e) { if (e instanceof Zotero.HTTP.UnexpectedStatusException) { if (e.status == 412) { - return this.UPLOAD_RESULT_LIBRARY_CONFLICT; + throw e; } // On 5xx, delay and retry