Hi,
I've considered that bug on sourceforge. According to it,"other editors (e.g. gvim) also have problems saving to a dav:// URL, but they do not blank the file. gedit works just fine here.". GEdit seems to work via GIO, so the only more or less reliable solution is to use GIO where possible.
Btw, the bugs with GVFS didn't appear with GNOME 2.26 (and probably before), so I think we can safely use fopen() and fprintf()/fwrite() there. Then, your proposal about version separation (use GIO with GLib>=2.16 and fopen()/g_file_set_contents() with other) is extremely attractive. Do you know if there is a way to get GLib version at runtime, not at compile-time (so that there is no need to rebuild all the packages for different versions)?
I'm going to start working on it; if this is OK, I'll send a patch ASAP.
Tue, 30 Mar 2010 23:35:22 +0200 письмо от Enrico Tr?ger enrico.troeger@uvena.de:
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
-- Get my GPG key from http://www.uvena.de/pub.asc
ATTACHMENT: application/pgp-signature _______________________________________________ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Новые Карты@Mail.Ru с пробками и спутниками! http://r.mail.ru/cln4831/map.mail.ru/