www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit e03cf637b6edf4bd0b9906b3aa432234036e4dd9
parent 7f43ca9503a9f3d7e6762fb41aff1e3cb406dd9a
Author: Dan Stillman <dstillman@zotero.org>
Date:   Mon,  2 Nov 2015 03:20:29 -0500

Fix 412 handling

Diffstat:
Mchrome/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 @@ -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