<br><br><div class="gmail_quote">On 3 April 2010 13:20, Colomban Wendling <span dir="ltr"><<a href="mailto:lists.ban@herbesfolles.org">lists.ban@herbesfolles.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
Lex Trotman a écrit :<br>
><br>
><br>
> 2010/4/2 Алексей Антипов <<a href="mailto:1a_antipov@mail.ru">1a_antipov@mail.ru</a> <mailto:<a href="mailto:1a_antipov@mail.ru">1a_antipov@mail.ru</a>>><br>
<div class="im">><br>
>     As goes from GLib sources, the final replace strategy is<br>
>     backend-dependent.<br>
>     For local files: (from GLib sources, gio/glocalfileoutputstream.c,<br>
>     handle_overwrite_open):<br>
>      /* We use two backup strategies.<br>
>       * The first one (which is faster) consist in saving to a<br>
>       * tmp file then rename the original file to the backup and the<br>
>       * tmp file to the original name. This is fast but doesn't work<br>
>       * when the file is a link (hard or symbolic) or when we can't<br>
><br>
><br>
> I don't understand why it fails with a hard link, all files *are* hard<br>
> links so that means it would never work, do you understand what they mean?<br>
</div>I think they mean it would break the links, which is actually true: hard<br>
links points to the file's data, then a simple rename() does NOT break<br>
the link, and then the hard links would not point to the newly created<br>
file. Of course, it is not a problem if the file have only one link<br>
(simple file) since there is only one entry point.<br></blockquote><div><br>Yes, its badly worded :-) what is meant is that if a file has more than one hard link, all the other links continue to point to the original data.  For mine this is correct and expected behaviour so "won't work" comment threw me.<br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
> I don't understand why the C library calls fopen and fwrite call GIO,<br>
> for file systems supported natively on the platform they should directly<br>
> perform actions on that file system, for others they would have to go<br>
> via fuse and the path you have shown, unless GVFS is taking over the<br>
> whole file system and forcing all file system operations via itself :-(<br>
> very bad if so.  Impacts performance, reliability and maintainability.<br>
</div>I think too that GVFS have nothing to do here, only a "real" or FUSE FS,<br>
nothing more. But I might be wrong.<br></blockquote><div><br>I'd say we are right, gio local file handling uses fopen and fwrite, it would be an infinite loop if they were re-directed.<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div class="im"><br>
> Geany also needs to be portable<br>
> so it needs to handle GIO when available and non-GIO when not and<br>
> windows with similar levels of competence.<br>
</div>Yes, but I think it should not prevent a specific improvement if it<br>
worth it (e.g. if it fixes a real problem that can't be fixed reliably<br>
with more generic code). I mean "similar" should be taken only as "don't<br>
let one be bad", not "don't let one be amazing".<br></blockquote><div><br>Agree, I should have said to the same minimum level of competence. <br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div class="im"><br>
> If there are problems in the<br>
> backends I would not expect Geany to compensate for them.<br>
</div>Of course not (I think).<br>
<br>
<br>
I think the best way is to use GIO when possible, since it is meant for<br>
that; and it is unrealistic to handle each and every limitation of<br>
filesystems from inside a program (like geany or whatever). What if an<br>
unknown remote FS doesn't support feature X or Y (or not the way they<br>
may be expected to) we rely on? The only viable solution is a specific<br>
handling of this kind of cases. What a better place than an IO<br>
abstraction layer?<br>
But of course then, the point is the trust (and actual correctness) in<br>
the IO layer. Even if GIO have probably many bugs (as each and every<br>
program or library), I think it could be trusted:<br>
1) it is an IO layer, then it is its role;<br>
2) it is an active project that (should) fix the defects when found;<br>
3) well... as said above, could we better trust our own code? I mean,<br>
GIO is not a funky joke made by drunk peoples, and it is not only used<br>
by two monkeys on a starship: bugs will be found and fixed.<br></blockquote><div><br>oh, have you seen the code then, millions of extraterrestrial space monkeys and typewriters come to mind  :-) <br><br>seriously though you are correct.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Of course this doesn't apply if the IO layer doesn't support the needed<br>
feature (actually, safe file saving with correct permissions).<br>
<br></blockquote><div><br>At least for local filesystems g_file_replace will try to copy permissions to the temporary file and if that does not work will fall back to copying the content to the backup file, truncating the original file and writing to that, so in most cases it should end up with the initial permissions.  But if the write then fails how do you find and restore the backup???<br>
<br>g_file_replace therefore solves the initial problem with using g_file_save_contents for safe file saving :-) and is what Alexey's patch does, thanks<br><br>Cheers<br>Lex<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

That's my two pounds... but consider I didn't go deep in the subject and<br>
it may be a somewhat wrong consideration, don't take this as if said<br>
after months of tests, thoughts and audit.<br>
<br>
<br>
Regards,<br>
<font color="#888888">Colomban<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Geany-devel mailing list<br>
<a href="mailto:Geany-devel@uvena.de">Geany-devel@uvena.de</a><br>
<a href="http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel" target="_blank">http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel</a><br>
</div></div></blockquote></div><br>