summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-03-01 18:16:33 +0000
committerChristian Persch <chpe@src.gnome.org>2004-03-01 18:16:33 +0000
commitec64dc73df5f93278f40e80111b0b332549824bc (patch)
treea7154269ae19dfcb02ea3537b41c203b07d12db5
parent937f23e417318217832d28c30112dbc98f0bde22 (diff)
downloadepiphany-ec64dc73df5f93278f40e80111b0b332549824bc.tar.gz
If reading the bookmarks file, or re-importing the bookmarks from the rdf
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.
-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;
}
}