After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 691794 - Bookmarks lost after crash
Bookmarks lost after crash
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: Bookmarks
3.6.x (obsolete)
Other Linux
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
: 662549 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-01-15 16:46 UTC by Bastien Nocera
Modified: 2013-11-29 10:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ephy-node-db: use g_file_set_contents() when saving to disk (2.46 KB, patch)
2013-01-23 11:56 UTC, Claudio Saavedra
committed Details | Review
ephy-bookmarks-export: use g_file_set_contents() when saving to RDF (2.30 KB, patch)
2013-01-23 11:56 UTC, Claudio Saavedra
committed Details | Review

Description Bastien Nocera 2013-01-15 16:46:05 UTC
The bookmarks saving in epiphany uses ephy_file_switch_temp_file(), which is racy and doesn't save the file atomically. Instead, the bookmarks code should be using g_file_set_contents() which will create a temporary file, and move it over the original. If either of those fail, the original file will remain untouched.
Comment 1 Claudio Saavedra 2013-01-23 10:22:51 UTC
So you say that the promise of ephy_file_switch_temp_file() of saving atomically is just bs? That's bad.
Comment 2 Claudio Saavedra 2013-01-23 11:56:08 UTC
Created attachment 234178 [details] [review]
ephy-node-db: use g_file_set_contents() when saving to disk

Since g_file_set_contents() is atomic and already takes care of saving
first to a temporary file, we don't need to use
ephy_file_switch_temp_file().
Comment 3 Claudio Saavedra 2013-01-23 11:56:11 UTC
Created attachment 234179 [details] [review]
ephy-bookmarks-export: use g_file_set_contents() when saving to RDF
Comment 4 Claudio Saavedra 2013-01-23 11:56:45 UTC
Next would be nuke that method as it's no longer used.
Comment 5 Claudio Saavedra 2013-01-23 11:58:23 UTC
Review of attachment 234178 [details] [review]:

::: lib/ephy-node-db.c
@@ +512,3 @@
 		ret = -1;
 	}
+	xmlBufferFree (buffer);

This should go into the failed: section.
Comment 6 Bastien Nocera 2013-01-23 12:21:52 UTC
(In reply to comment #1)
> So you say that the promise of ephy_file_switch_temp_file() of saving
> atomically is just bs? That's bad.

It's racy because it checks for the file's existence by hand, instead of relying on the retval from the system calls.
Comment 7 Xan Lopez 2013-01-25 18:08:58 UTC
Review of attachment 234178 [details] [review]:

Looks good, agreed with your comment there.
Comment 8 Xan Lopez 2013-01-25 18:10:24 UTC
Review of attachment 234179 [details] [review]:

::: src/bookmarks/ephy-bookmarks-export.c
@@ +434,2 @@
 		{
+			g_warning ("Error saving bookmarks as RDF: %s\n", error->message);

There's kinda a log already below no? I guess we should have one or the other, but not both.
Comment 9 Claudio Saavedra 2013-01-27 16:04:15 UTC
Attachment 234178 [details] pushed as fdf27e6 - ephy-node-db: use g_file_set_contents() when saving to disk
Attachment 234179 [details] pushed as 213b032 - ephy-bookmarks-export: use g_file_set_contents() when saving to RDF
Comment 10 Claudio Saavedra 2013-01-27 16:04:52 UTC
I also removed already the racy method.
Comment 11 Claudio Saavedra 2013-11-29 10:02:06 UTC
*** Bug 662549 has been marked as a duplicate of this bug. ***