This commit is contained in:
sspitzer%mozilla.org 2007-12-04 08:03:27 +00:00
Родитель c0561ebaca
Коммит 888545efed
3 изменённых файлов: 37 добавлений и 14 удалений

Просмотреть файл

@ -339,14 +339,15 @@ BrowserGlue.prototype = {
// if we need to force a migration (due to a schema change)
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var importBookmarks = false;
try {
var prefBranch = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
importBookmarks = prefBranch.getBoolPref("browser.places.importBookmarksHTML");
} catch(ex) {}
if (!importBookmarks) {
// Call it here for Fx3 profiles created before the Places folder
// has been added, otherwise it's called during import.
@ -358,7 +359,7 @@ BrowserGlue.prototype = {
getService(Ci.nsIProperties);
var bookmarksFile = dirService.get("BMarks", Ci.nsILocalFile);
if (bookmarksFile.exists()) {
// import the file
try {
@ -388,6 +389,11 @@ BrowserGlue.prototype = {
}
}
}
else {
// this covers the case the places database gets corrupted (or removed)
// but the bookmarks html backup file does not exist
this.ensurePlacesDefaultQueriesInitialized();
}
},
/**

Просмотреть файл

@ -1702,17 +1702,20 @@ var PlacesUtils = {
var allBookmarksId;
try {
leftPaneRoot = prefs.getIntPref("browser.places.leftPaneFolderId");
// Build the leftPaneQueries Map
delete this.leftPaneQueries;
this.leftPaneQueries = {};
var items = this.annotations.getItemsWithAnnotation(ORGANIZER_QUERY_ANNO, { });
for (var i=0; i < items.length; i++) {
var queryName = this.annotations
.getItemAnnotation(items[i], ORGANIZER_QUERY_ANNO);
this.leftPaneQueries[queryName] = items[i];
// if the pref is set to -1 then we must create a new root because we have a new places.sqlite
if (leftPaneRoot != -1) {
// Build the leftPaneQueries Map
delete this.leftPaneQueries;
this.leftPaneQueries = {};
var items = this.annotations.getItemsWithAnnotation(ORGANIZER_QUERY_ANNO, { });
for (var i=0; i < items.length; i++) {
var queryName = this.annotations
.getItemAnnotation(items[i], ORGANIZER_QUERY_ANNO);
this.leftPaneQueries[queryName] = items[i];
}
delete this.leftPaneFolderId;
return this.leftPaneFolderId = leftPaneRoot;
}
delete this.leftPaneFolderId;
return this.leftPaneFolderId = leftPaneRoot;
}
catch (ex) { }

Просмотреть файл

@ -110,7 +110,10 @@
#define PREF_AUTOCOMPLETE_ENABLED "urlbar.autocomplete.enabled"
#define PREF_DB_CACHE_PERCENTAGE "history_cache_percentage"
#define PREF_BROWSER_IMPORT_BOOKMARKS "browser.places.importBookmarksHTML"
#define PREF_BROWSER_IMPORT_DEFAULTS "browser.places.importDefaults"
#define PREF_BROWSER_CREATEDDEFAULTQUERIES "browser.places.createdDefaultQueries"
#define PREF_BROWSER_LEFTPANEFOLDERID "browser.places.leftPaneFolderId"
// Default (integer) value of PREF_DB_CACHE_PERCENTAGE from 0-100
// This is 6% of machine memory, giving 15MB for a user with 256MB of memory.
// The most that will be used is the size of the DB file. Normal history sizes
@ -502,6 +505,17 @@ nsNavHistory::InitDBFile(PRBool aForceInit)
if (prefs) {
rv = prefs->SetBoolPref(PREF_BROWSER_IMPORT_BOOKMARKS, PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
rv = prefs->SetBoolPref(PREF_BROWSER_IMPORT_DEFAULTS, PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
// if the places.sqlite gets deleted/corrupted the queries should be created again
rv = prefs->SetBoolPref(PREF_BROWSER_CREATEDDEFAULTQUERIES, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
// we must create a new Organizer left pane folder root, the old will not be valid anymore
rv = prefs->SetIntPref(PREF_BROWSER_LEFTPANEFOLDERID, -1);
NS_ENSURE_SUCCESS(rv, rv);
}
}