From 973e5dccd2e75bb58c5e532f137b6c7f1391eb5e Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 20 Nov 2003 17:16:24 +0000 Subject: Make xml saving low disk safe. 2003-11-20 Marco Pesenti Gritti * src/ephy-session.c: (ephy_session_save): Make xml saving low disk safe. --- ChangeLog | 6 ++++++ src/ephy-session.c | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 62db0477d..17127ef59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-11-20 Marco Pesenti Gritti + + * src/ephy-session.c: (ephy_session_save): + + Make xml saving low disk safe. + 2003-11-20 Marco Pesenti Gritti * src/ephy-window.c: (show_embed_popup): diff --git a/src/ephy-session.c b/src/ephy-session.c index 18900e87e..75347d7cf 100644 --- a/src/ephy-session.c +++ b/src/ephy-session.c @@ -496,7 +496,7 @@ ephy_session_save (EphySession *session, { xmlTextWriterPtr writer; GList *w; - char *save_to; + char *save_to, *tmp_file; int ret; LOG ("ephy_sesion_save %s", filename) @@ -508,9 +508,11 @@ ephy_session_save (EphySession *session, } save_to = get_session_filename (filename); + tmp_file = g_strconcat (save_to, ".tmp", NULL); /* FIXME: do we want to turn on compression? */ - writer = xmlNewTextWriterFilename (save_to, 0); + writer = xmlNewTextWriterFilename (tmp_file, 0); + g_free (tmp_file); if (writer == NULL) { return FALSE; @@ -554,6 +556,14 @@ ephy_session_save (EphySession *session, out: xmlFreeTextWriter (writer); + if (ret >= 0) + { + if (ephy_file_switch_temp_file (save_to, tmp_file) == FALSE) + { + ret = -1; + } + } + g_free (save_to); STOP_PROFILER ("Saving session") -- cgit v1.2.3