From 959c42dca4daf95946fea1bcf68613d56e5642b7 Mon Sep 17 00:00:00 2001 From: Philipp von Weitershausen Date: Tue, 9 Nov 2010 13:53:50 -0800 Subject: [PATCH] Bug 610375 - Make bookmark folders not sync last [r=mconnor] --- services/sync/modules/engines/bookmarks.js | 5 +++++ services/sync/tests/unit/test_bookmark_store.js | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index 6a6c4cbeb2e1..d8c8afe147a8 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -45,6 +45,7 @@ const Cu = Components.utils; const PARENT_ANNO = "weave/parent"; const PREDECESSOR_ANNO = "weave/predecessor"; const SERVICE_NOT_SUPPORTED = "Service not supported on this platform"; +const FOLDER_SORTINDEX = 1000000; try { Cu.import("resource://gre/modules/PlacesUtils.jsm"); @@ -862,6 +863,10 @@ BookmarksStore.prototype = { }, _calculateIndex: function _calculateIndex(record) { + // Ensure folders have a very high sort index so they're not synced last. + if (record.type == "folder") + return FOLDER_SORTINDEX; + // For anything directly under the toolbar, give it a boost of more than an // unvisited bookmark let index = 0; diff --git a/services/sync/tests/unit/test_bookmark_store.js b/services/sync/tests/unit/test_bookmark_store.js index 785e6fe4c4c5..03dd3ea85174 100644 --- a/services/sync/tests/unit/test_bookmark_store.js +++ b/services/sync/tests/unit/test_bookmark_store.js @@ -42,6 +42,13 @@ function run_test() { _("The calculated sort index is based on frecency data."); do_check_true(newrecord.sortindex >= 150); + + _("Folders have high sort index to ensure they're synced first."); + let folder_id = Svc.Bookmark.createFolder(Svc.Bookmark.toolbarFolder, + "Test Folder", 0); + let folder_guid = Svc.Bookmark.getItemGUID(folder_id); + let folder_record = store.createRecord(folder_guid, "http://fake/uri"); + do_check_eq(folder_record.sortindex, 1000000); } finally { _("Clean up."); store.wipe();