GNOME Bugzilla – Bug 167867
Autosave should not save unmodified files.
Last modified: 2005-02-27 16:16:37 UTC
Please describe the problem: A file I edited was mysteriously overwritten periodically with an older version. After a few hours of sucking I found out that 1. The file was opened twice, but I did not notice it - the tab belonging to the other instance was not on the screen (as I had about 15 files open) 2. Autosave was turned on (with 1 minute). As a result, gedit autosaved the instance I was not working on with the old content, so the file on the disk was sometimes different than the instance I was actively working on. Worst is, when I left the editor, it kept the wrong autosaved version on the disk, so I lost about 2 hours of work. Steps to reproduce: 1. Turn autosave on. 2. Open a file twice, write different content into them 3. Save one instance 4. Without touching anything in gedit, watch it automatically change. Actual results: The file changes "automatically' Expected results: 1. I would not let the same file to be edited in different tabs/windows, or 2. the different tabs/windows for the same file should be synchronized. Does this happen every time? yes Other information:
hmmm... it seems we have two different problems here: 1. Autosave should not save unmodified files. 2. Do not let the same file in different tabs/windows (see bug #143646) Since point 2 is already tracked in another bug, I'm changing the summary of this bug to refer to point 1
Reading the code and testing it, I'm sure gedit 2.9.x does not autosave unmodified documents. I have also tried to follows the steps you reported, but I failed to reproduce it. Which version of gedit are you using? It may be this bug is present in 2.8.x since we changed the autosave code during the 2.9.x development cycle. pbor: are you able to reproduce it?
My version is 2.8.2. According to gedit-document.c the autosave timer is started in - gedit_document_save - gedit_document_save_as - gedit_document_set_readonly so maybe the file has to be saved at least once to start autosaving it. BTW I was thinking why is it worth just fixing the autosave issue and now I think it doesn't help enough. The main problem remains there: it is possible to edit two concurrent versions of the same file and saving both of them can cause data loss. It doesn't matter whether the files were autosaved or they was saved manually (this can happen - first you edit and save one version then "accidentally" (without noticing it) you continue working on the other version. After saving it then quiting the editor causes the data entered in the first version to be lost. As a first aid I think if the same file is to be opened twice (based on the full filename including the path from the root directory), gedit should switch to the already opened version. This way at least the data loss could be avoided. Compared to this implementing multiple views for the same file is absolutely not important.
We analyzed your report again yesterday and as, you reported in comment #3, "the file has to be saved at least once to start autosaving it". We will fix this problem for 2.10.0 We are aware there could be possible data loss if a user is editing two concurrent versions of the same file and the specific problem with discussion of possible solutions is tracked on bug #143646. We don't want to implement multiple views of the same file, but we would avoid a user could accidentally open the same file twice. We will fix solve this problem in the next major release of gedit (2.12) since it is now to late to fix it for 2.10.
Created attachment 38003 [details] [review] Committed patch
Fixed the problem : "the file has to be saved at least once to start autosaving it". The remaining part of the problem is tracked on bug #143646 (marking as duplicate). *** This bug has been marked as a duplicate of 143646 ***