Bug 1148252 - gracefully handle an attempt to upload a new item when the server already has it. r=adw
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 27 Mar 2015 13:10:20 +1100
changeset 266263 024efc08edd84682c4f56573de18718157f76782
parent 266262 180361c8634a8a34936ddd849eda5aee603d3132
child 266264 bf843cab375a04c7823cf8cac76b3f132555ca01
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1148252
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1148252 - gracefully handle an attempt to upload a new item when the server already has it. r=adw
browser/components/readinglist/Sync.jsm
--- a/browser/components/readinglist/Sync.jsm
+++ b/browser/components/readinglist/Sync.jsm
@@ -273,18 +273,23 @@ SyncImpl.prototype = {
         // "See Other": An item with the URL already exists.  Mark the item as
         // having material changes, and reconcile and upload it in the
         // material-changes phase.
         // TODO
         continue;
       }
       // Note that the server seems to return a 200 if an identical item already
       // exists, but we shouldn't be uploading identical items in this phase in
-      // normal usage, so treat 200 as an unexpected response.
-      if (response.status != 201) {
+      // normal usage. But if something goes wrong locally (eg, we upload but
+      // get some error even though the upload worked) we will see this.
+      // So allow 200 but log a warning.
+      if (response.status == 200) {
+        log.debug("Attempting to upload a new item found the server already had it", response);
+        // but we still process it.
+      } else if (response.status != 201) {
         this._handleUnexpectedResponse("uploading a new item", response);
         continue;
       }
       let item = yield this.list.itemForURL(response.body.url);
       yield this._updateItemWithServerRecord(item, response.body);
     }
   }),