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 340766 - all notes can be deleted under certain circumstances
all notes can be deleted under certain circumstances
Status: RESOLVED FIXED
Product: gnome-applets
Classification: Other
Component: stickynotes
2.14.x
Other All
: Normal critical
: ---
Assigned To: gnome-applets Maintainers
gnome-applets Maintainers
: 357000 (view as bug list)
Depends on: 340769
Blocks:
 
 
Reported: 2006-05-05 18:32 UTC by ergosys
Modified: 2010-12-10 08:30 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
patch to write atomically (2.30 KB, patch)
2006-10-08 20:04 UTC, Tom Tromey
none Details | Review
updated patch (5.90 KB, patch)
2006-10-11 22:24 UTC, Tom Tromey
accepted-commit_now Details | Review

Description ergosys 2006-05-05 18:32:43 UTC
Please describe the problem:
On two occasions, after a system crash I have found all of my notes to be gone.
Investigating with strace, it appears that the ~/.gnome2/stickynotes_applet file
is written over without using the safe-save method (write to backup, then
rename).  If this method were used, data loss would be less likely. 

Steps to reproduce:


Actual results:


Expected results:


Does this happen every time?


Other information:
ubuntu dapper beta
Comment 1 Tom Tromey 2006-09-26 22:19:13 UTC
I looked at this.

From what I can see, xmlSaveFormatFile does not do an atomic save
(writing to a temp file and then renaming).  Instead it just writes
to the file directly.

It is simple to change stickynotes.c to write the XML document
to a temporary buffer and then to use g_file_set_contents to do
an atomic save.  I have a patch to do this, but it is incomplete,
as I have not written code to recover from an error (e.g., should
it bring up a dialog?)

Also I need to figure out how to test it.
I'm happy to post what I've got here if that would help anybody.
Comment 2 Tom Tromey 2006-10-08 20:04:05 UTC
Created attachment 74312 [details] [review]
patch to write atomically

This patch changes the sticky notes applet to write atomically,
using g_file_set_contents.  If the write fails it will pop up a dialog
asking the user whether he wants to try again.  I'm not super happy
with the wording of the dialog (or the buttons).

I tested this by making ~/.gnome2 unwriteable, then moving a note
(triggering a save).  The dialog correctly popped up, and the old
file was not removed.
Comment 3 Benoît Dejean 2006-10-09 22:45:57 UTC
why g_file_set_contents would be atomic ? i think it's not. Why don't you use write a copy and then mv it (just like vim, gedit, etc do) as suggested in the original report ? Because your patch may just fail to write the file over and over and as a result, its content would be incoherent.
Comment 4 Tom Tromey 2006-10-09 22:53:33 UTC
I'm just following the documentation for g_file_set_contents,
which says that it is atomic.

http://developer.gnome.org/doc/API/2.0/glib/glib-File-Utilities.html#g-file-set-contents

Comment 5 Benoît Dejean 2006-10-10 06:53:37 UTC
"This write is atomic in the sense that it is first written to a temporary file which is then renamed to the final name."

great !
Comment 6 Danielle Madeley 2006-10-11 07:37:11 UTC
It seems like if you answer "no", it's just going to bug you again in 5 minutes, but it seems you've already solved this problem in bug 340769.
Comment 7 Tom Tromey 2006-10-11 22:24:17 UTC
Created attachment 74527 [details] [review]
updated patch

Here's an updated patch that removes the dead code and the
schema entry.

Yeah, even with a "no" it will keep asking on future saves.  And even
with the bug #340769 patch, this will be after typing, after moving
a window, etc.

I'm not really sure what is best.  On the one hand this lets you know
something is wrong -- and if it something like running out of disk space,
or unwriteable directory, etc, you actually could fix it.  On the other
hand if you can't fix it this dialog will be a constant irritant.

I couldn't think of anything reasonable that would fall into the "can't
fix it" case though.
Comment 8 Danielle Madeley 2006-10-19 07:21:57 UTC
We should put this in, so we at least we have atomic saves. We can change the behaviour of the dialog later on if needs be.
Comment 9 Tom Tromey 2006-10-20 22:52:40 UTC
I'd be delighted to check this in (plus the other patch)
but I haven't had word back from the admins about reactivating
my account.  So, it may be a while.
Comment 10 Kjartan Maraas 2006-11-16 12:08:00 UTC
Commited this to HEAD. Was it intended for the stable branch as well?
Comment 11 Tom Tromey 2007-01-08 21:31:44 UTC
*** Bug 357000 has been marked as a duplicate of this bug. ***
Comment 12 Leeteq 2010-12-10 08:30:55 UTC
An open issue keeps referring to this bug, which does not seem to be resolved:
https://bugs.launchpad.net/ubuntu/+source/gnome-applets/+bug/61570/comments/20

It seems that several people are under the impression that this is an ongoing issue, maybe it should be reopened here, or perhaps its reference removed at bugs.launchpad.net?