From 30147177c1155ec98fa32ccb08deaa7f3fac0592 Mon Sep 17 00:00:00 2001 From: Edward Lee Date: Wed, 21 Apr 2010 11:10:32 -0700 Subject: [PATCH] Bug 437277 - update daily backup before first bookmark sync [r=mconnor] Share an archiveBookmarks function that wraps the PlacesUtils call to be used from storage.wipe and first sync. --- services/sync/modules/engines/bookmarks.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index 58e18356b93..093eb5e978a 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -55,6 +55,14 @@ Cu.import("resource://weave/stores.js"); Cu.import("resource://weave/trackers.js"); Cu.import("resource://weave/type_records/bookmark.js"); +function archiveBookmarks() { + // Some nightly builds of 3.7 don't have this function + try { + PlacesUtils.archiveBookmarksFile(null, true); + } + catch(ex) {} +} + // Lazily initialize the special top level folders let kSpecialIds = {}; [["menu", "bookmarksMenuFolder"], @@ -126,6 +134,10 @@ BookmarksEngine.prototype = { _syncStartup: function _syncStart() { SyncEngine.prototype._syncStartup.call(this); + // For first-syncs, make a backup for the user to restore + if (this.lastSync == 0) + archiveBookmarks(); + // Lazily create a mapping of folder titles and separator positions to GUID this.__defineGetter__("_lazyMap", function() { delete this._lazyMap; @@ -936,10 +948,8 @@ BookmarksStore.prototype = { }, wipe: function BStore_wipe() { - // some nightly builds of 3.7 don't have this function - try { - PlacesUtils.archiveBookmarksFile(null, true); - } catch(e) {} + // Save a backup before clearing out all bookmarks + archiveBookmarks(); for (let [guid, id] in Iterator(kSpecialIds)) if (guid != "places")