[Geany-devel] Safe file saving - permissions issue

Алексей Антипов 1a_antipov at xxxxx
Fri Apr 2 23:51:18 UTC 2010


Please find the patch in attachment. When building with GIO, it would use g_file_replace_contents
Also, for those who are interested, I have found the reason for strange behaviour with gvfs-smb. The proposed patch is here: https://bugzilla.gnome.org/show_bug.cgi?id=614696

Fri, 02 Apr 2010 12:12:36 +0400 письмо от Алексей Антипов<1a_antipov at mail.ru>:

> Sure, it does not alter permissions.
> 
> I suppose that with make_backup=TRUE it would first (attempt to) copy previous file to a backup file,
> and only then write a new one. The annoying thing is that it would not delete a backup file, and the
> only way to get its name is to "guess" (usually for "filename" the backup name is "filename~").
> Probably the backup file can be left as it is, so a user gets a copy of his/her old data; those who are
> annoyed with that can simply turn the option off.
> 
> I've created a patch which requires some final testing; I'll send it today or tomorrow (can test only with smb:// and 
> sftp://, 'cause have nothing else:))
> 
> Thu, 1 Apr 2010 17:07:59 +0100 письмо от Nick Treleaven <nick.treleaven at btinternet.com>:
> 
> > On Thu, 1 Apr 2010 12:41:13 +0100
> > Nick Treleaven <nick.treleaven at btinternet.com> wrote:
> > 
> > > > 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.
> > > 
> > > BTW There is another problem that file saving should solve - not
> > > losing existing file data when there is no space to save the new file.
> > > Does g_file_replace_contents() handle this problem? (g_file_set_contents
> > > () does handle this but as you mention has other problems).
> > 
> > According to the docs for g_file_replace, which g_file_replace_contents
> > uses internally, this case may be handled:
> > 
> > "This will try to replace the file in the safest way possible so that
> > any errors during the writing will not affect an already existing copy
> > of the file. For instance, for local files it may write to a temporary
> > file and then atomically rename over the destination when the stream is
> > closed."
> > http://library.gnome.org/devel/gio/unstable/GFile.html#g-file-replace
> > 
> > Hopefully it still keeps permissions if the rename is done(!)
> > 
> > Regards,
> > Nick
> > _______________________________________________
> > Geany-devel mailing list
> > Geany-devel at uvena.de
> > http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
> > 
> 
> 
> Тесты новейших гаджетов на Hi-tech.Mail.Ru
> http://r.mail.ru/cln5823/hi-tech.mail.ru/
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
> 


Лучшие предложения интернет-магазинов на Товары@Mail.Ru 
http://r.mail.ru/cln4267/torg.mail.ru/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 40_gio_file_saving.dpatch
Type: application/octet-stream
Size: 1620 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20100403/766e8ea6/attachment.obj>


More information about the Devel mailing list