aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-file-helpers.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-05-26 03:39:09 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-05-26 03:39:09 +0800
commit9ae7960ca8c3ca534ba07bb6d58b430ee9cda413 (patch)
tree552cf6c6fded80d05acaea44eeef46f7509d21ad /lib/ephy-file-helpers.c
parentc159006b08ac492649715c9a3ce55f258e199f97 (diff)
downloadgsoc2013-epiphany-9ae7960ca8c3ca534ba07bb6d58b430ee9cda413.tar
gsoc2013-epiphany-9ae7960ca8c3ca534ba07bb6d58b430ee9cda413.tar.gz
gsoc2013-epiphany-9ae7960ca8c3ca534ba07bb6d58b430ee9cda413.tar.bz2
gsoc2013-epiphany-9ae7960ca8c3ca534ba07bb6d58b430ee9cda413.tar.lz
gsoc2013-epiphany-9ae7960ca8c3ca534ba07bb6d58b430ee9cda413.tar.xz
gsoc2013-epiphany-9ae7960ca8c3ca534ba07bb6d58b430ee9cda413.tar.zst
gsoc2013-epiphany-9ae7960ca8c3ca534ba07bb6d58b430ee9cda413.zip
Try to fix node removal problems. I cant repro crashes ... but they are
2003-05-25 Marco Pesenti Gritti <marco@it.gnome.org> * configure.in: * embed/ephy-favicon-cache.c: (ephy_favicon_cache_save): * embed/ephy-history.c: (ephy_history_save), (hosts_removed_cb), (pages_removed_cb), (unref_empty_host), (page_removed_from_host_cb), (connect_page_removed_from_host), (ephy_history_init), (ephy_history_add_host): * lib/ephy-file-helpers.c: (ephy_file_save_xml): * lib/ephy-file-helpers.h: * lib/ephy-node.c: (callback), (ephy_node_emit_signal), (real_remove_child), (ephy_node_dispose): * lib/ephy-node.h: * lib/ephy-state.c: (ephy_states_save): * lib/widgets/ephy-tree-model-node.c: (root_child_removed_cb): * src/bookmarks/ephy-bookmarks-export.c: (ephy_bookmarks_export_rdf): * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_save), (bookmarks_removed_cb), (topics_removed_cb): Try to fix node removal problems. I cant repro crashes ... but they are quite hard to reproduce. Use a save_xml helper that is low disk safe. * src/ephy-automation.c: (impl_ephy_automation_loadurl): Use OPEN_PAGE when an url is passed
Diffstat (limited to 'lib/ephy-file-helpers.c')
-rw-r--r--lib/ephy-file-helpers.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 6ca68be28..6577bc06b 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -365,3 +365,60 @@ ephy_file_find (const char *path,
ephy_find_file_recursive (path, fname, &ret, 0, maxdepth);
return ret;
}
+
+gboolean
+ephy_file_save_xml (const char *xml_file, xmlDocPtr doc)
+{
+ char *tmp_file;
+ char *old_file;
+ gboolean old_exist;
+ gboolean retval = TRUE;
+
+ tmp_file = g_strconcat (xml_file, ".tmp", NULL);
+ old_file = g_strconcat (xml_file, ".old", NULL);
+
+ if (!xmlSaveFormatFile (tmp_file, doc, 1))
+ {
+ g_warning ("Failed to write XML data to %s", tmp_file);
+ goto failed;
+ }
+
+ old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS);
+
+ if (old_exist)
+ {
+ if (rename (xml_file, old_file) < 0)
+ {
+ g_warning ("Failed to rename %s to %s", xml_file, old_file);
+ retval = FALSE;
+ goto failed;
+ }
+ }
+
+ if (rename (tmp_file, xml_file) < 0)
+ {
+ g_warning ("Failed to rename %s to %s", tmp_file, xml_file);
+
+ if (rename (old_file, xml_file) < 0)
+ {
+ g_warning ("Failed to restore %s from %s", xml_file, tmp_file);
+ }
+ retval = FALSE;
+ goto failed;
+ }
+
+ if (old_exist)
+ {
+ if (unlink (old_file) < 0)
+ {
+ g_warning ("Failed to delete old file %s", old_file);
+ }
+ }
+
+ failed:
+ g_free (old_file);
+ g_free (tmp_file);
+
+ return retval;
+}
+