aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--src/bookmarks/ephy-bookmarks.c40
2 files changed, 49 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index fec5fc8d9..ff5924df3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2004-03-01 Christian Persch <chpe@cvs.gnome.org>
+ * src/bookmarks/ephy-bookmarks.c: (backup_file),
+ (ephy_bookmarks_init):
+
+ If reading the bookmarks file, or re-importing the bookmarks from the
+ rdf file fails, back up those files so that the user can afterwards
+ try to manually recover his bookmarks. Fixes bug #128308.
+
+2004-03-01 Christian Persch <chpe@cvs.gnome.org>
+
* src/bookmarks/ephy-bookmarks-import.c: (xbel_parse_folder),
(xbel_parse_xbel), (ephy_bookmarks_import_xbel):
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index f15e20ccd..928813f81 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -586,6 +586,34 @@ disable_bookmark_editing_notifier (GConfClient *client,
}
static void
+backup_file (const char *original_filename, const char *extension)
+{
+ char *template, *backup_filename;
+ int result = 0;
+
+ template = g_strconcat (original_filename, ".backup-XXXXXX", NULL);
+ backup_filename = ephy_file_tmp_filename (template, extension);
+
+ if (backup_filename != NULL)
+ {
+ result = rename (original_filename, backup_filename);
+ }
+
+ if (result >= 0)
+ {
+ g_message ("Your old bookmarks file was backed up as \"%s\".\n",
+ backup_filename);
+ }
+ else
+ {
+ g_warning ("Backup failed! Your old bookmarks file was lost.\n");
+ }
+
+ g_free (template);
+ g_free (backup_filename);
+}
+
+static void
ephy_bookmarks_init (EphyBookmarks *eb)
{
GValue value = { 0, };
@@ -682,8 +710,20 @@ ephy_bookmarks_init (EphyBookmarks *eb)
EPHY_BOOKMARKS_XML_ROOT,
EPHY_BOOKMARKS_XML_VERSION) == FALSE)
{
+ /* save the corrupted files so the user can late try to
+ * manually recover them. See bug #128308.
+ */
+
+ g_warning ("Could not read bookmarks file \"%s\", trying to "
+ "re-import bookmarks from \"%s\"\n",
+ eb->priv->xml_file, eb->priv->rdf_file);
+
+ backup_file (eb->priv->xml_file, "xml");
+
if (ephy_bookmarks_import_rdf (eb, eb->priv->rdf_file) == FALSE)
{
+ backup_file (eb->priv->rdf_file, "rdf");
+
eb->priv->init_defaults = TRUE;
}
}