Bug 1119282 - Fix the sync bookmark validator cycle detection to correctly get folder contents. r?kitcambridge draft
authorMark Banner <standard8@mozilla.com>
Thu, 29 Jun 2017 10:49:10 -0700
changeset 602120 840ab91b0a6851679df34017ae7c7ed02a9a7dcb
parent 601609 4535bfe17353c08486753fa100215c76e19121b3
child 602344 08b5106a36ff0599d6b38d35e0ed7b3c1fcd10b9
push id66285
push userbmo:standard8@mozilla.com
push dateThu, 29 Jun 2017 17:49:43 +0000
reviewerskitcambridge
bugs1119282
milestone56.0a1
Bug 1119282 - Fix the sync bookmark validator cycle detection to correctly get folder contents. r?kitcambridge MozReview-Commit-ID: BjRD5wKbAoy
services/sync/modules/bookmark_validator.js
--- a/services/sync/modules/bookmark_validator.js
+++ b/services/sync/modules/bookmark_validator.js
@@ -224,24 +224,31 @@ XPCOMUtils.defineLazyGetter(this, "SYNCE
 ]);
 
 class BookmarkValidator {
 
   async canValidate() {
     return !await PlacesSyncUtils.bookmarks.havePendingChanges();
   }
 
-  _followQueries(recordMap) {
+  async _followQueries(recordMap) {
     for (let [guid, entry] of recordMap) {
       if (entry.type !== "query" && (!entry.bmkUri || !entry.bmkUri.startsWith(QUERY_PROTOCOL))) {
         continue;
       }
       // Might be worth trying to parse the place: query instead so that this
       // works "automatically" with things like aboutsync.
-      let queryNodeParent = PlacesUtils.getFolderContents(entry, false, true);
+      let id;
+      try {
+        id = await PlacesUtils.promiseItemId(guid);
+      } catch (ex) {
+        // guid isn't found, so this doesn't exist locally.
+        continue;
+      }
+      let queryNodeParent = PlacesUtils.getFolderContents(id, false, true);
       if (!queryNodeParent || !queryNodeParent.root.hasChildren) {
         continue;
       }
       queryNodeParent = queryNodeParent.root;
       let queryNode = null;
       let numSiblings = 0;
       let containerWasOpen = queryNodeParent.containerOpen;
       queryNodeParent.containerOpen = true;
@@ -352,17 +359,17 @@ class BookmarkValidator {
           child.parent = treeNode;
           child.parentid = guid;
           treeNode.childGUIDs.push(child.guid);
         }
       }
     }
     await traverse(clientTree, false);
     clientTree.id = "places";
-    this._followQueries(recordsByGuid);
+    await this._followQueries(recordsByGuid);
     return records;
   }
 
   /**
    * Process the server-side list. Mainly this builds the records into a tree,
    * but it also records information about problems, and produces arrays of the
    * deleted and non-deleted nodes.
    *