Bug 1069410 - CloudSync should not be using setItemIndex. r=mak
authorAlan K <akligman@mozilla.com>
Tue, 23 Sep 2014 09:11:00 +0200
changeset 206877 6c0248e2e44bf1259859a65e43ac98e8db6b9646
parent 206876 c105e80ce9239dc18770fcc55cde6f969ad9b34e
child 206878 11ba7e5e883492bece776d1e85c965a5b7c6ba93
push id27543
push userryanvm@gmail.com
push dateWed, 24 Sep 2014 20:02:22 +0000
treeherdermozilla-central@435732392989 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1069410
milestone35.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 1069410 - CloudSync should not be using setItemIndex. r=mak
services/cloudsync/CloudSyncBookmarks.jsm
--- a/services/cloudsync/CloudSyncBookmarks.jsm
+++ b/services/cloudsync/CloudSyncBookmarks.jsm
@@ -13,16 +13,17 @@ Cu.import("resource://services-common/ut
 Cu.import("resource://services-crypto/utils.js");
 Cu.import("resource://gre/modules/PlacesUtils.jsm");
 Cu.import("resource:///modules/PlacesUIUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
                                   "resource://gre/modules/NetUtil.jsm");
 
 Cu.import("resource://gre/modules/Promise.jsm");
+Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/CloudSyncPlacesWrapper.jsm");
 Cu.import("resource://gre/modules/CloudSyncEventSource.jsm");
 Cu.import("resource://gre/modules/CloudSyncBookmarksFolderCache.jsm");
 
 const ITEM_TYPES = [
   "NULL",
   "BOOKMARK",
   "FOLDER",
@@ -479,17 +480,25 @@ let RootFolder = function (rootId, rootN
                   return PlacesWrapper.moveItem(localId, parent, index);
                 }
               )
             .then(deferred.resolve, deferred.reject);
           promises.push(deferred.promise);
         }
 
         if (item.hasOwnProperty("index") && !item.hasOwnProperty("parent")) {
-          promises.push(PlacesWrapper.bookmarks.setItemIndex(localId, item.index));
+          promises.push(Task.spawn(function* () {
+            let localItem = (yield getLocalItemsById([item.id]))[0];
+            let parent = yield PlacesWrapper.guidToLocalId(localItem.parent);
+            let index = item.index;
+            if (CS_FOLDER & item.type) {
+              folderCache.setParent(localId, parent);
+            }
+            yield PlacesWrapper.moveItem(localId, parent, index);
+          }));
         }
 
         Promise.all(promises)
                .then(deferred.resolve, deferred.reject);
       }
     );
 
     return deferred.promise;