CINXE.COM
Attachment 155020 Details for Bug 218636 – bookmarks-save-backup-0.patch
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta property="og:type" content="website"> <meta property="og:title" content=" Attachment 155020 Details for Bug 218636 – bookmarks-save-backup-0.patch"> <meta name="viewport" content="width=1024"> <meta name="color-scheme" content="dark light"> <meta name="generator" content="Bugzilla 20241119.1"> <meta name="bugzilla-global" content="dummy" id="bugzilla-global" data-bugzilla="{"api_token":"","config":{"basepath":"\/"},"constant":{"COMMENT_COLS":80},"param":{"maxattachmentsize":"10240","maxusermatches":"50","splinter_base":"\/page.cgi?id=splinter.html&ignore=\/","use_markdown":"1"},"string":{"TextEditor":{"command_bold":"Bold","command_bulleted_list":"Bulleted list","command_code":"Code","command_heading":"Heading","command_italic":"Italic","command_link":"Link","command_numbered_list":"Numbered list","command_quote":"Quote","comment_editor":"Comment Editor","edit":"Edit","etiquette_link":{"href":"page.cgi?id=etiquette.html","text":"Etiquette"},"guidelines_link":{"href":"page.cgi?id=bug-writing.html","text":"Bug Writing Guidelines"},"loading":"Loading…","markdown_link":{"href":"https:\/\/guides.github.com\/features\/mastering-markdown\/","text":"Markdown supported"},"preview":"Preview","preview_error":"Preview could not be loaded. Please try again later.","text_editor":"Text Editor","toolbar_label":"Markdown text-formatting toolbar"},"bug":"bug","bug_type_required":"You must select a Type for this bug","component_required":"You must select a Component for this bug","description_required":"You must enter a Description for this bug","short_desc_required":"You must enter a Summary for this bug","version_required":"You must select a Version for this bug"},"user":{"is_new":true,"login":""}}"> <meta name="google-site-verification" content="JYXIuR9cAlV7fLmglSrc_4UaJS6Wzh5Mdxiorqu5AQc" /> <title> Attachment 155020 Details for Bug 218636 – bookmarks-save-backup-0.patch</title> <link href="/static/v20241119.1/skins/standard/global.css" rel="stylesheet" type="text/css"><link href="/static/v20241119.1/skins/standard/attachment.css" rel="stylesheet" type="text/css"><link href="/static/v20241119.1/js/jquery/ui/jquery-ui-min.css" rel="stylesheet" type="text/css"><link href="/static/v20241119.1/js/jquery/ui/jquery-ui-structure-min.css" rel="stylesheet" type="text/css"><link href="/static/v20241119.1/js/jquery/ui/jquery-ui-theme-min.css" rel="stylesheet" type="text/css"><link href="/static/v20241119.1/skins/lib/prism.css" rel="stylesheet" type="text/css"><link href="/static/v20241119.1/extensions/Needinfo/web/styles/needinfo.css" rel="stylesheet" type="text/css"><link href="/static/v20241119.1/extensions/Review/web/styles/badge.css" rel="stylesheet" type="text/css"><link href="/static/v20241119.1/extensions/Review/web/styles/review.css" rel="stylesheet" type="text/css"><link href="/static/v20241119.1/skins/standard/text-editor.css" rel="stylesheet" type="text/css"> <script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/js/jquery/jquery-min.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/js/jquery/ui/jquery-ui-min.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/js/jquery/plugins/devbridgeAutocomplete/devbridgeAutocomplete-min.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/js/global.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/js/util.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/js/widgets.js"></script> <script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P">BUGZILLA.value_descs = JSON.parse('{\"bug_status\":{},\"resolution\":{\"\":\"---\"}}'); review_suggestions = { _mentors: [ ], 'Bookmarks & History': [ ], _end: 1 }; static_component = 'Bookmarks & History'; </script> <script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/js/text-editor.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/js/attachment.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/js/field.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/js/lib/prism.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/extensions/GoogleAnalytics/web/js/analytics.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/js/lib/md5.min.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/extensions/Review/web/js/badge.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/extensions/Review/web/js/review.js"></script> <link href="/static/v20241119.1/skins/lib/fontawesome.min.css" rel="stylesheet" type="text/css"> <link href="/static/v20241119.1/skins/lib/fontawesome-brands.min.css" rel="stylesheet" type="text/css"> <link href="/static/v20241119.1/skins/lib/fontawesome-solid.min.css" rel="stylesheet" type="text/css"> <link rel="search" type="application/opensearchdescription+xml" title="Bugzilla@Mozilla" href="/search_plugin.cgi"><link rel="shortcut icon" href="/extensions/BMO/web/images/favicon.ico"><meta name="google-analytics" content="UA-36116321-3" data-location="https://bugzilla.mozilla.org/attachment/edit" data-title="Attachment 155020 Details for Bug 218636 &ndash; bookmarks-save-backup-0.patch"> <script async src="https://www.google-analytics.com/analytics.js"></script><meta name="robots" content="noarchive"> </head> <body class="bugzilla-mozilla-org skin-standard no_javascript"> <div id="wrapper"> <header id="header" role="banner" aria-label="Global Header"> <div class="inner" role="none"> <button type="button" class="iconic ghost" id="open-menu-drawer" aria-label="Open Site Menu"> <span class="icon" aria-hidden="true" data-icon="menu"></span> </button><div id="header-external-links" class="dropdown" role="none"> <button type="button" id="header-external-menu-button" class="dropdown-button minor" aria-label="Show Mozilla Menu" aria-expanded="false" aria-haspopup="true" aria-controls="header-external-menu"> <img src="/static/v20241119.1/extensions/BMO/web/images/moz-fav-one-color-white-rgb.svg" width="32" height="32" alt=""> </button> <ul class="dropdown-content right" id="header-external-menu" role="menu" aria-label="Mozilla Menu" style="display:none;"> <li role="none"> <a href="https://www.mozilla.org/" role="menuitem"> <span class="label" role="none">Mozilla Home</span> </a> </li> <li role="separator"></li> <li role="none"> <a href="https://www.mozilla.org/privacy/websites/" role="menuitem"> <span class="label" role="none">Privacy</span> </a> </li> <li role="none"> <a href="https://www.mozilla.org/privacy/websites/#cookies" role="menuitem"> <span class="label" role="none">Cookies</span> </a> </li> <li role="none"> <a href="https://www.mozilla.org/about/legal/" role="menuitem"> <span class="label" role="none">Legal</span> </a> </li> </ul> </div> <h1 id="header-title" class="title" role="none"> <a class="header-button" href="https://bugzilla.mozilla.org/home" title="Go to home page"> <span aria-label="Go to Bugzilla Home Page">Bugzilla</span> </a> </h1> <form id="header-search" class="quicksearch" action="/buglist.cgi" data-no-csrf role="search" aria-label="Search Bugs"> <button type="button" class="iconic ghost" id="show-searchbox" aria-label="Search Bugs"> <span class="icon" aria-hidden="true" data-icon="search"></span> </button> <div class="searchbox-outer dropdown" role="combobox" aria-label="Quick Search" aria-haspopup="listbox" aria-owns="header-search-dropdown" aria-expanded="false"> <span class="icon" aria-hidden="true" data-icon="search"></span> <input id="quicksearch_top" class="dropdown-button" name="quicksearch" autocomplete="off" value="" accesskey="s" placeholder="Search Bugs" title="Enter a bug number or some search terms" role="searchbox" aria-controls="header-search-dropdown" aria-label="Search Terms"><div id="header-search-dropdown" class="dropdown-content dropdown-panel right" role="listbox" style="display: none;"> <div id="header-search-dropdown-wrapper" role="none"> <section id="header-search-dropdown-help" role="group" aria-label="Help"> <footer role="none"> <a href="/page.cgi?id=quicksearch.html">Quick Search Tips</a> <a href="/query.cgi?format=advanced">Advanced Search</a> </footer> </section> </div> </div> </div> </form> <nav id="header-nav" role="menubar" aria-label="Site Links"> <ul class="links" role="none"><li role="none"> <a class="header-button" href="/describecomponents.cgi" title="Browse bugs by component" role="menuitem"> <span class="icon" aria-hidden="true" data-icon="category"></span> <span class="label" role="none">Browse</span> </a> </li> <li role="none"> <a class="header-button" href="/query.cgi?format=advanced" title="Search bugs using various criteria" role="menuitem"> <span class="icon" aria-hidden="true" data-icon="pageview"></span> <span class="label" role="none">Advanced Search</span> </a> </li> <li role="none"> <a class="header-button" href="/enter_bug.cgi" title="File a new bug" role="menuitem"> <span class="icon" aria-hidden="true" data-icon="add_box"></span> <span class="label" role="none">New Bug</span> </a> </li> </ul> <div class="dropdown" role="none"> <button type="button" id="header-tools-menu-button" class="header-button dropdown-button minor" title="More tools…" role="menuitem" aria-label="Show More Tools Menu" aria-expanded="false" aria-haspopup="true" aria-controls="header-tools-menu"> <span class="icon" aria-hidden="true" data-icon="more_horiz"></span> </button> <ul class="dropdown-content left" id="header-tools-menu" role="menu" aria-label="More Tools Menu" style="display:none;"><li role="none"> <a href="/report.cgi" role="menuitem"> <span class="icon" aria-hidden="true" data-icon="analytics"></span> <span class="label" role="none">Reports</span> </a> </li> <li role="separator"></li> <li role="none"> <a href="https://bmo.readthedocs.io/en/latest/" target="_blank" role="menuitem"> <span class="icon" aria-hidden="true" data-icon="help"></span> <span class="label" role="none">Documentation</span> </a> </li> </ul> </div> </nav> <ul id="header-login" class="links" role="none"><li id="mini_login_container_top" role="none"> <a id="login_link_top" href="/index.cgi?GoAheadAndLogIn=1" class='show_mini_login_form header-button' data-qs-suffix="_top" role="button"> <span class="icon" aria-hidden="true" data-icon="login"></span> <span class="label" role="none">Log In</span> </a> <div id="mini_login_top" class="mini-popup mini_login bz_default_hidden"> <form method="post" action="/github.cgi"> <input type="hidden" name="github_token" value="Ba53DiViKWCF8EYtHYEwxJqEbSJBHx6HtmnOEAPlYcjmySd1kIdVqTqhjQ3FfJvwC0Sd3oRMbH09NZRwGvM8Ql6iQnXTXG4Nz8h3t09fGzpCYTqGsEZ7stuPyJcACCC4mLSs8TA5ajTFpaLgS6CLZuDRYlEhDqZeEWTMXSeHWUuaGt6Uopl0IakyCtDe1oAFgZhxYZ4D22uBwahvL2zZ7wFiG6teVXcphUKfGWXELw3DuoVxsArIfG8Ex9mOq7Fj"> <input type="hidden" name="target_uri" value="https://bugzilla.mozilla.org/attachment.cgi"> <button type="submit"> <i class="fab fa-github"></i> Log In with GitHub </button> </form> <div class="method-separator">or</div> <form action="/attachment.cgi?id=155020&action=edit" method="POST" data-qs-suffix="_top"> <input id="Bugzilla_login_top" class="bz_login" name="Bugzilla_login" title="Login" placeholder="Email" aria-label="Email" type="email" required > <input class="bz_password" id="Bugzilla_password_top" name="Bugzilla_password" type="password" title="Password" placeholder="Password" aria-label="Password" required > <input class="bz_password bz_default_hidden bz_mini_login_help" type="text" id="Bugzilla_password_dummy_top" value="password" title="Password" > <span class="remember-outer"> <input type="checkbox" id="Bugzilla_remember_top" name="Bugzilla_remember" value="on" class="bz_remember" checked> <label for="Bugzilla_remember_top">Remember me</label> </span> <input type="hidden" name="Bugzilla_login_token" value="1732390093-7DOl2vHyQDl4ZcO87_MdZdH8C5h5kfwWlm8pun-9ICg"> <input type="submit" name="GoAheadAndLogIn" value="Log In" id="log_in_top" class="check_mini_login_fields" data-qs-suffix="_top"> <a href="#" id="hide_mini_login_top" aria-label="Close" class="close-button hide_mini_login_form" data-qs-suffix="_top"> <span class="icon" aria-hidden="true"></span> </a> </form> <div class="footer"> <a href="/createaccount.cgi">Create an Account</a> · <a id="forgot_link_top" href="/index.cgi?GoAheadAndLogIn=1#forgot" class='show_forgot_form' data-qs-suffix="_top">Forgot Password</a> </div> </div> <div id="forgot_form_top" class="mini-popup mini_forgot bz_default_hidden"> <form action="/token.cgi" method="post"> <input type="email" name="loginname" size="20" placeholder="Email" aria-label="Email" required> <input id="forgot_button_top" value="Reset Password" type="submit"> <input type="hidden" name="a" value="reqpw"> <input type="hidden" id="token_top" name="token" value="1732390093-0ZkPEr9_A_F2cxS0wbU0KPLi6ISbIp_jSzBIQ7GZ_Zw"> <a href="#" class="close-button hide_forgot_form" aria-label="Close" data-qs-suffix="_top"> <span class="icon" aria-hidden="true"></span> </a> </form> </div> </li> </ul> </div> <dialog id="menu-drawer" inert aria-label="Site Menu"> <div class="drawer-inner" role="none"> <div class="header" role="none"> <button type="button" class="iconic ghost" id="close-menu-drawer" aria-label="Close Site Menu"> <span class="icon" aria-hidden="true" data-icon="close"></span> </button> </div> <ul role="menu" aria-label="Site Links"><li role="none"> <a class="header-button" href="/describecomponents.cgi" title="Browse bugs by component" role="menuitem"> <span class="icon" aria-hidden="true" data-icon="category"></span> <span class="label" role="none">Browse</span> </a> </li> <li role="none"> <a class="header-button" href="/query.cgi?format=advanced" title="Search bugs using various criteria" role="menuitem"> <span class="icon" aria-hidden="true" data-icon="pageview"></span> <span class="label" role="none">Advanced Search</span> </a> </li> <li role="none"> <a class="header-button" href="/enter_bug.cgi" title="File a new bug" role="menuitem"> <span class="icon" aria-hidden="true" data-icon="add_box"></span> <span class="label" role="none">New Bug</span> </a> </li><li role="none"> <a href="/report.cgi" role="menuitem"> <span class="icon" aria-hidden="true" data-icon="analytics"></span> <span class="label" role="none">Reports</span> </a> </li> <li role="separator"></li> <li role="none"> <a href="https://bmo.readthedocs.io/en/latest/" target="_blank" role="menuitem"> <span class="icon" aria-hidden="true" data-icon="help"></span> <span class="label" role="none">Documentation</span> </a> </li> </ul> </div> </dialog> </header> <main id="bugzilla-body" tabindex="-1"> <aside id="message-container" role="complementary"> <noscript> <div class="noscript"> <div class="inner"> <p>Please enable JavaScript in your browser to use all the features on this site.</p> </div> </div> </noscript> </aside> <div id="main-inner"> <h2> Attachment 155020 Details for <a class="bz_bug_link bz_status_RESOLVED bz_closed" title="RESOLVED FIXED - backup bookmark file" href="/show_bug.cgi?id=218636">Bug 218636</a></h2> <form method="post" action="/attachment.cgi" onsubmit="normalizeComments();"> <input type="hidden" name="bugid" value="218636"> <input type="hidden" name="id" value="155020"> <input type="hidden" name="action" value="update"> <input type="hidden" name="contenttypemethod" value="manual"> <input type="hidden" name="delta_ts" value="2004-08-08 05:43:54"> <div id="attachment_info" class="attachment_info read"> <div id="attachment_attributes"> <div id="attachment_information_read_only" class=""> <div class="title">[patch] <span class="" title="">bookmarks-save-backup-0.patch </span> </div> <div class="details">bookmarks-save-backup-0.patch (text/plain), 9.04 KB, created by <span class="vcard vcard_24534"><span class="fn">Vladimir Vukicevic [:vlad] [:vladv] (needinfo me, slow to respond)</span> </span> </div> </div> <div id="attachment_information_edit"> <span class="bz_hide"> (<a href="javascript:toggle_attachment_details_visibility();">hide</a>) </span> <div id="attachment_description"> <label for="description">Description:</label> <textarea name="description" id="description" class="block bz_hidden_option" wrap="soft" rows="3" cols="25">bookmarks-save-backup-0.patch</textarea> </div> <div id="attachment_filename"> <label for="filename">Filename:</label> <input type="text" size="20" class="text block bz_hidden_option" id="filename" name="filename" value="bookmarks-save-backup-0.patch"> </div> <div id="attachment_mimetype"> <label for="contenttypeentry">MIME Type:</label> <input type="text" size="20" class="text block bz_hidden_option" id="contenttypeentry" name="contenttypeentry" value="text/plain"> </div> <div id="attachment_creator"> <span class="label">Creator:</span> <span class="vcard vcard_24534"><span class="fn">Vladimir Vukicevic [:vlad] [:vladv] (needinfo me, slow to respond)</span> </span> </div> <div id="attachment_size"> <span class="label">Size:</span> 9.04 KB </div> <div id="attachment_ispatch"> <input type="checkbox" id="ispatch" name="ispatch" value="1" checked="checked"> <label for="ispatch">patch</label> </div> <div class="readonly"> <div class="checkboxes"> <div id="attachment_isobsolete"> <input type="checkbox" id="isobsolete" name="isobsolete" value="1" > <label for="isobsolete">obsolete</label> </div> </div> </div> </div> <div id="attachment_view_window"> <div> <input type="hidden" name="markdown_off" value="0"><textarea name="comment" id="editFrame" class="bz_default_hidden" wrap="soft" disabled="disabled" rows="10" cols="80">>? nsBookmarksService.cpp.save >? q >Index: nsBookmarksService.cpp >=================================================================== >RCS file: /cvsroot/mozilla/browser/components/bookmarks/src/nsBookmarksService.cpp,v >retrieving revision 1.32.4.12 >diff -u -8 -p -r1.32.4.12 nsBookmarksService.cpp >--- nsBookmarksService.cpp 31 Jul 2004 02:22:39 -0000 1.32.4.12 >+++ nsBookmarksService.cpp 2 Aug 2004 20:46:57 -0000 >@@ -1621,17 +1621,18 @@ BookmarkParser::AssertTime(nsIRDFResourc > > //////////////////////////////////////////////////////////////////////// > // nsBookmarksService implementation > > nsBookmarksService::nsBookmarksService() : > mInner(nsnull), > mUpdateBatchNest(0), > mBookmarksAvailable(PR_FALSE), >- mDirty(PR_FALSE) >+ mDirty(PR_FALSE), >+ mNeedBackupUpdate(PR_FALSE) > > #if defined(XP_MAC) || defined(XP_MACOSX) > ,mIEFavoritesAvailable(PR_FALSE) > #endif > { } > > nsBookmarksService::~nsBookmarksService() > { >@@ -1713,33 +1714,29 @@ nsBookmarksService::Init() > observerService->AddObserver(this, "profile-before-change", PR_TRUE); > observerService->AddObserver(this, "profile-after-change", PR_TRUE); > observerService->AddObserver(this, "quit-application", PR_TRUE); > } > > rv = InitDataSource(); > NS_ENSURE_SUCCESS(rv, rv); > >- // bookmark timers and scheduling are disabled for 1.0, until >- // they can be fixed (bug 253478) >-#if 0 > /* timer initialization */ > busyResource = nsnull; > > if (!mTimer) > { > busySchedule = PR_FALSE; > mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv); > NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a timer"); > if (NS_FAILED(rv)) return rv; > mTimer->InitWithFuncCallback(nsBookmarksService::FireTimer, this, BOOKMARK_TIMEOUT, > nsITimer::TYPE_REPEATING_SLACK); > // Note: don't addref "this" as we'll cancel the timer in the nsBookmarkService destructor > } >-#endif > > // register this as a named data source with the RDF > // service. Do this *last*, because if Init() fails, then the > // object will be destroyed (leaving the RDF service with a > // dangling pointer). > rv = gRDF->RegisterDataSource(this, PR_FALSE); > if (NS_FAILED(rv)) return rv; > >@@ -1985,21 +1982,29 @@ nsBookmarksService::GetBookmarkToPing(ns > > void > nsBookmarksService::FireTimer(nsITimer* aTimer, void* aClosure) > { > nsBookmarksService *bmks = NS_STATIC_CAST(nsBookmarksService *, aClosure); > if (!bmks) return; > nsresult rv; > >+ if (bmks->mNeedBackupUpdate == PR_TRUE) >+ { >+ bmks->SaveToBackup(); >+ } >+ > if ((bmks->mBookmarksAvailable == PR_TRUE) && (bmks->mDirty == PR_TRUE)) > { > bmks->Flush(); > } > >+ // bookmark timers and scheduling are disabled for 1.0, until >+ // they can be fixed (bug 253478) >+#if 0 > if (bmks->busySchedule == PR_FALSE) > { > nsCOMPtr<nsIRDFResource> bookmark; > if (NS_SUCCEEDED(rv = bmks->GetBookmarkToPing(getter_AddRefs(bookmark))) && (bookmark)) > { > bmks->busyResource = bookmark; > > nsAutoString url; >@@ -2034,16 +2039,17 @@ nsBookmarksService::FireTimer(nsITimer* > } > } > #ifdef DEBUG_BOOKMARK_PING_OUTPUT > else > { > printf("nsBookmarksService::FireTimer - busy pinging.\n"); > } > #endif >+#endif > } > > > // stream observer methods > > NS_IMETHODIMP > nsBookmarksService::OnStartRequest(nsIRequest* request, nsISupports *ctxt) > { >@@ -4248,37 +4254,108 @@ nsBookmarksService::Flush() > { > nsCOMPtr<nsIFile> bookmarksFile; > rv = GetBookmarksFile(getter_AddRefs(bookmarksFile)); > > // Oh well, couldn't get the bookmarks file. Guess there > // aren't any bookmarks for us to write out. > if (NS_FAILED(rv)) return NS_OK; > >+ if (mNeedBackupUpdate) >+ SaveToBackup(); >+ > rv = WriteBookmarks(bookmarksFile, mInner, kNC_BookmarksRoot); >+ if (NS_SUCCEEDED(rv)) >+ mNeedBackupUpdate = PR_TRUE; > } > return rv; > } > > NS_IMETHODIMP > nsBookmarksService::FlushTo(const char *aURI) > { > // Do not ever implement this (security) > return NS_ERROR_NOT_IMPLEMENTED; > } > > > //////////////////////////////////////////////////////////////////////// > // Implementation methods > >+// save a copy of the last bookmarks file, if it exists, to bookmarks.bak >+void >+nsBookmarksService::SaveToBackup() >+{ >+ nsresult rv; >+ >+ nsCOMPtr<nsIFile> bookmarksFile; >+ rv = GetBookmarksFile(getter_AddRefs(bookmarksFile)); >+ >+ if (NS_FAILED(rv) || !bookmarksFile) >+ return; >+ >+ PRBool exists; >+ bookmarksFile->Exists(&exists); >+ >+ if (!exists) >+ return; >+ >+ nsCOMPtr<nsIFile> backupFile, parentFolder; >+ bookmarksFile->GetParent(getter_AddRefs(parentFolder)); >+ if (parentFolder) { >+ rv = bookmarksFile->CopyTo(parentFolder, NS_LITERAL_STRING("bookmarks.bak")); >+ if (NS_SUCCEEDED(rv)) >+ mNeedBackupUpdate = PR_FALSE; >+ } >+} >+ >+// Attempt to restore a truncated or non-existent bookmarks.html file >+// from the backup file generated by the last successful write. >+void >+nsBookmarksService::MaybeRestoreFromBackup(nsIFile* aBookmarkFile, nsIFile* aParentFolder) >+{ >+ if (!aBookmarkFile) >+ return; >+ >+ PRBool exists; >+ aBookmarkFile->Exists(&exists); >+ if (exists) >+ { >+ PRInt64 fileSize; >+ aBookmarkFile->GetFileSize(&fileSize); >+ if (fileSize == 0) >+ { >+ aBookmarkFile->Remove(PR_FALSE); >+ exists = PR_FALSE; >+ } >+ } >+ if (!exists) >+ { >+ nsCOMPtr<nsIFile> backupFile; >+ aParentFolder->Clone(getter_AddRefs(backupFile)); >+ if (aParentFolder && backupFile) >+ { >+ backupFile->Append(NS_LITERAL_STRING("bookmarks.bak")); >+ backupFile->Exists(&exists); >+ if (exists) >+ { >+ nsAutoString bookmarksFileName; >+ aBookmarkFile->GetLeafName(bookmarksFileName); >+ >+ backupFile->CopyTo(aParentFolder, bookmarksFileName); >+ } >+ } >+ } >+} >+ > nsresult > nsBookmarksService::GetBookmarksFile(nsIFile* *aResult) > { > nsresult rv; >- nsCOMPtr<nsIFile> bookmarksFile; >+ nsCOMPtr<nsIFile> bookmarksFile, parentFolder; > > // First we see if the user has set a pref for the location of the > // bookmarks file. > nsCOMPtr<nsIPref> prefServ(do_GetService(kPrefCID, &rv)); > if (NS_SUCCEEDED(rv)) > { > nsXPIDLCString prefVal; > rv = prefServ->CopyCharPref("browser.bookmarks.file", >@@ -4287,27 +4364,36 @@ nsBookmarksService::GetBookmarksFile(nsI > { > rv = NS_NewNativeLocalFile(prefVal, PR_TRUE, > (nsILocalFile**)(nsIFile**) getter_AddRefs(bookmarksFile)); > > if (NS_SUCCEEDED(rv)) > { > *aResult = bookmarksFile; > NS_ADDREF(*aResult); >+ >+ bookmarksFile->GetParent(getter_AddRefs(parentFolder)); >+ if (parentFolder) >+ MaybeRestoreFromBackup(*aResult, parentFolder); >+ > return NS_OK; > } > } > } > > > // Otherwise, we look for bookmarks.html in the current profile > // directory using the magic directory service. > rv = NS_GetSpecialDirectory(NS_APP_BOOKMARKS_50_FILE, aResult); > NS_ENSURE_SUCCESS(rv, rv); > >+ NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(parentFolder)); >+ if (parentFolder) >+ MaybeRestoreFromBackup(*aResult, parentFolder); >+ > return NS_OK; > } > > > #if defined(XP_MAC) || defined(XP_MACOSX) > > nsresult > nsBookmarksService::ReadFavorites() >Index: nsBookmarksService.h >=================================================================== >RCS file: /cvsroot/mozilla/browser/components/bookmarks/src/nsBookmarksService.h,v >retrieving revision 1.14.4.2 >diff -u -8 -p -r1.14.4.2 nsBookmarksService.h >--- nsBookmarksService.h 17 Jul 2004 05:33:33 -0000 1.14.4.2 >+++ nsBookmarksService.h 2 Aug 2004 20:46:57 -0000 >@@ -87,16 +87,17 @@ protected: > > PRUint32 htmlSize; > PRInt32 mUpdateBatchNest; > nsXPIDLString mPersonalToolbarName; > PRBool mBookmarksAvailable; > PRBool mDirty; > PRBool mBrowserIcons; > PRBool busySchedule; >+ PRBool mNeedBackupUpdate; > > public: > // bookmark resources used to indicate that a livemark > // is either loading or failed to load. > nsCOMPtr<nsIRDFResource> mLivemarkLoadingBookmark; > nsCOMPtr<nsIRDFResource> mLivemarkLoadFailedBookmark; > > protected: >@@ -173,16 +174,19 @@ protected: > > nsresult LoadBookmarks(); > nsresult InitDataSource(); > > nsresult GetLastModifiedFolders(nsISimpleEnumerator **aResult); > > nsresult UpdateLivemarkChildren(nsIRDFResource* aSource); > >+ void SaveToBackup(); >+ void MaybeRestoreFromBackup(nsIFile* aBookmarkFile, nsIFile* aParentFolder); >+ > // nsIStreamObserver methods: > NS_DECL_NSIREQUESTOBSERVER > > // nsIStreamListener methods: > NS_DECL_NSISTREAMLISTENER > > // nsIObserver methods: > NS_DECL_NSIOBSERVER </textarea> <iframe id="viewFrame" src="/attachment.cgi?id=155020" sandbox> <b>You cannot view the attachment while viewing its details because your browser does not support IFRAMEs. <a href="/attachment.cgi?id=155020">View the attachment on a separate page</a>.</b> </iframe> <script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P"> <!-- var patchviewerinstalled = 0; var attachment_id = 155020; if (typeof document.getElementById == "function") { var patchviewerinstalled = 1; document.write('<iframe id="viewDiffFrame" class="bz_default_hidden"><\/iframe>'); document.write('<button type="button" id="viewDiffButton" onclick="viewDiff(attachment_id, patchviewerinstalled);">View Attachment As Diff<\/button>'); document.write('<button type="button" id="viewRawButton" onclick="viewRaw(patchviewerinstalled);" class="bz_default_hidden">View Attachment As Raw<\/button>'); } //--> </script> </div> </div> <div id="attachment_comments_and_flags"> <div id="attachment_flags"><p><b>Flags:</b></p> <span title="Ben Goodger (use ben at mozilla dot org for email)">bugs</span>: review+<br> <span title="Ben Goodger (use ben at mozilla dot org for email)">bugs</span>: approval-aviary+<br> </div> </div> </div> </div> </form> <div id="attachment_actions"> <span class="label">Actions:</span> <a href="/attachment.cgi?id=155020">View</a> | <a href="/attachment.cgi?id=155020&action=diff">Diff</a>  | <a href="/page.cgi?id=splinter.html&ignore=&bug=218636&attachment=155020">Review</a> </div> <div id="attachment_list"> Attachments on <a class="bz_bug_link bz_status_RESOLVED bz_closed" title="RESOLVED FIXED - backup bookmark file" href="/show_bug.cgi?id=218636">bug 218636</a>: <span class="bz_obsolete"> <a href="/attachment.cgi?id=154340&action=edit" title="simple patch">154340</a> </span> | 155020 </div><link rel="stylesheet" href="/static/v20241119.1/extensions/FlagTypeComment/web/styles/ftc.css"> <script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P" src="/static/v20241119.1/extensions/FlagTypeComment/web/js/ftc.js"></script><script nonce="0Xl6JJMfmehFH5F9JXHc6MhW2tcv54YF7xQCEAo2ve6YOZ4P"> $(function() { REVIEW.init_mandatory(); }); </script> </div> </main> </div> </body> </html>