On Tue, 30 Mar 2010 16:28:25 +0400, Алексей wrote:
Hi,
I've found one more issue with Geany's "Safe file saving" option. When using g_file_set_contents(), file ownership and permissions are replaced with those for a new file. That fully conforms to GLib documentation (http://library.gnome.org/devel/glib/unstable/glib-File-Utilities.html#g-file...), but is not good sometimes (e.g. editing an executable script file). I
this is why I hate that way of saving files and why this option in Geany is hidden and disabled by default.
propose to use GIO API (GFile) instead of g_file_set_contents; the patch is attached. This solution, however, raises some questions:
- It does work for my system (Ubuntu 9.10), but will it work for
others, especially Windows? It seems that GIO is also available on Win32, but it requires some testing
- This cannot be named "Safe" file saving, as it does not create a
backup first (we can call g_file_replace_contents with make_backup = TRUE, but it would not delete this backup file when the operation completes). Maybe there should be some other configuration option to use (or not to use) this setting? Or should I replace "unsafe" file saving with GIO functions instead of replacing "safe"? Or even more - make this option work like in GEdit (which, I suppose, uses g_file_replace_contents for both cases, with make_backup=TRUE in "safe" case), adding the corresponding checkbox to preferences dialog? What do you think?
Using the GIO API would require GLib 2.16. Currently we depend on 2.8. Technically, we surely could do it conditionally but that would make the could less readable, harder to maintain (it's already a mess with the GIO file monitoring which doesn't work as it should :( ) and finally, since to make any more use of this function than the current "unsafe" save method, we need the make_backup flag set to TRUE. In that case, we would need to delete the backup file after a successful save operation. I'm not totally against it but it sounds like quite some overhead to me.
Btw, there is a bug report[1] about the patch you sent a while ago. Maybe you want to have a look when you have time for.
[1] http://sourceforge.net/tracker/index.php?func=detail&aid=2961598&gro...
Regards, Enrico