On Sun, 27 Apr 2008 12:37:28 +0200, FD Cami francois.cami@free.fr wrote:
It may be that one way to do it is :
- move "file" to "file~"
- save memory buffer to "file"
- remove "file~"
Since this does not scale very well for big files, there should be some on/off option in preferences.
Well, this has no real effect in comparison to the current code.
It has. If step #2 "save memory buffer to file" fails, you do not remove file~. You do not lose all data, which is the current behaviour. I should have explained the logic better.
I meant move and delete files has no effect for big files. The logic in your suggestion was pretty clear. Sorry for the confusion.
I am going to work on that, unless a better idea comes up.
I'm not sure whether this is necessary. Wait a few days, I recently written a "backupcopy" plugin which copies the current file to a given directory after it was saved. So, this has basically the same effect as the the left "file~" in case of an error. But instead of the (IMO) ugly "~" extension, the extension can be configured, e.g. to contain a timestamp.
If your filesystem is full, I fail to see how this avoids losing data.
It doesn't. But your suggestion doesn't too. The idea is when your filesystem is full, there is no way to save the current changes in your document in Geany. This should be clear. With the backupcopy plugin you always have a copy of the last saved state of your file together with a timestamp. So, even if the current file is emptied by the failed write operation, you still have the backup of the last save operation. It is basically the same as you suggested only that the filename extension and the path for the backup files is configurable by default (through the plugin configuration).
I guess using the backupcopy plugin is probably enough to solve the problem together with a dialog box reporting the problem to the user (as Jeff suggested).
The dialog box is subject to the same race-condition problem I
Not really as the dialog box tells the user *after* the failed write operation not before. I really don't want to add any code to check for disk size.
explained above. Also, it will not work for windows users, because they mostly have a single partition, which is full or not, so you cannot save to another location (ok, perhaps a USB key or network drive) easily.
Nowadays this is probably also true for many Linux installations. But this is not what I want to do. I think we really shouldn't do much more than trying to write and tell the user if it failed or not. The only additional thing would be the backupcopy plugin or your "mv, write, delete" way.
And I also think it is sufficient to add a general dialog box telling the user the write operation while saving the file has failed, giving him the reason why it has failed (no space left, permission denied, ...). IMO it is not necessary to tell the user he should free some disk space to save the file, isn't this quite obvious?
And as I told before, when the system of the user is running out of disk space there are most probably bigger problems than the changes in the current file in Geany.
Yes, but losing the content of the file makes it even worse.
As long as Geany is running, the content is still there.
Regards, Enrico