aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-03-02 02:16:33 +0800
committerChristian Persch <chpe@src.gnome.org>2004-03-02 02:16:33 +0800
commitec64dc73df5f93278f40e80111b0b332549824bc (patch)
treea7154269ae19dfcb02ea3537b41c203b07d12db5 /src/bookmarks
parent937f23e417318217832d28c30112dbc98f0bde22 (diff)
downloadgsoc2013-epiphany-ec64dc73df5f93278f40e80111b0b332549824bc.tar
gsoc2013-epiphany-ec64dc73df5f93278f40e80111b0b332549824bc.tar.gz
gsoc2013-epiphany-ec64dc73df5f93278f40e80111b0b332549824bc.tar.bz2
gsoc2013-epiphany-ec64dc73df5f93278f40e80111b0b332549824bc.tar.lz
gsoc2013-epiphany-ec64dc73df5f93278f40e80111b0b332549824bc.tar.xz
gsoc2013-epiphany-ec64dc73df5f93278f40e80111b0b332549824bc.tar.zst
gsoc2013-epiphany-ec64dc73df5f93278f40e80111b0b332549824bc.zip
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.
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/ephy-bookmarks.c40
1 files changed, 40 insertions, 0 deletions
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;
}
}