зеркало из https://github.com/mozilla/pjs.git
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.
This commit is contained in:
Родитель
12f3abb6e4
Коммит
30147177c1
|
@ -55,6 +55,14 @@ Cu.import("resource://weave/stores.js");
|
||||||
Cu.import("resource://weave/trackers.js");
|
Cu.import("resource://weave/trackers.js");
|
||||||
Cu.import("resource://weave/type_records/bookmark.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
|
// Lazily initialize the special top level folders
|
||||||
let kSpecialIds = {};
|
let kSpecialIds = {};
|
||||||
[["menu", "bookmarksMenuFolder"],
|
[["menu", "bookmarksMenuFolder"],
|
||||||
|
@ -126,6 +134,10 @@ BookmarksEngine.prototype = {
|
||||||
_syncStartup: function _syncStart() {
|
_syncStartup: function _syncStart() {
|
||||||
SyncEngine.prototype._syncStartup.call(this);
|
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
|
// Lazily create a mapping of folder titles and separator positions to GUID
|
||||||
this.__defineGetter__("_lazyMap", function() {
|
this.__defineGetter__("_lazyMap", function() {
|
||||||
delete this._lazyMap;
|
delete this._lazyMap;
|
||||||
|
@ -936,10 +948,8 @@ BookmarksStore.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
wipe: function BStore_wipe() {
|
wipe: function BStore_wipe() {
|
||||||
// some nightly builds of 3.7 don't have this function
|
// Save a backup before clearing out all bookmarks
|
||||||
try {
|
archiveBookmarks();
|
||||||
PlacesUtils.archiveBookmarksFile(null, true);
|
|
||||||
} catch(e) {}
|
|
||||||
|
|
||||||
for (let [guid, id] in Iterator(kSpecialIds))
|
for (let [guid, id] in Iterator(kSpecialIds))
|
||||||
if (guid != "places")
|
if (guid != "places")
|
||||||
|
|
Загрузка…
Ссылка в новой задаче