[Geany-devel] Improve catching of project write failure

Lex Trotman elextr at xxxxx
Mon Feb 7 00:25:06 UTC 2011


2011/2/7 Enrico Tröger <enrico.troeger at uvena.de>:
> On Fri, 14 Jan 2011 17:11:35 +0100, Colomban wrote:
>
> Hey,
>
>>I found a bug in project creation (and save) check: if the project path
>>is a writable directory, update_config() won't see that write will
>>fail, and no error at all will be reported to the user (though write
>>will fail on a directory).
>>
>>I fixed this (in the attached patch) by:
>>
>>1) check whether the path is not a directory, because
>>utils_is_file_writeable() [1] returns TRUE in this case, but write will
>>still fail. Perhaps it should rather be fixed in
>>utils_is_file_writeable()?
>
> Could be done.
> Right now, utils_is_file_writable() has some logic to check whether the
> directory can be written if the given filename doesn't exist. And we
> use this check even in main.c:create_config_dir().
> But I'd agree to split this code into two functions:
> utils_is_file_writable()
> and
> utils_is_directory_writable()
>
>
>>2) check the return value of write_config(). This needed a little more
>>tuning for later calls to update_config() to work correctly, but now if
>>write actually fails, and even if update_config() reported no error, an
>>error will be displayed to the user and she will have a chance to
>>retry.
>
> Thanks for the patch, finally committed.
>
>
>>There is a last write_config() that may file silently though, the one
>>in project_close(); not sure how this may be fixed.
>
> I added a console warning at least for this case.
>
>
>>[1] shouldn't it be renamed utils_is_file_writable(), without the "e"?
>>Not sure though, but it looks weird to me and my spellchecker complains
>>about it...
>
> Oops.
> You are right. The funny thing is, usually I'm using two different
> dictionaries for German<->English. The one, freedict, knows about
> writeable but not writable. The other one (it's just called
> german-english) knows only about writable but not writeable.
> And my spellchecker also knows only writable so that one won :D.
> Maybe Nick or Lex as native speakers can shed some light.

I suppose you were looking for a single consistent answer, for
something in the English language?? :-)

English UK uses writable

English US uses both

Cheers
Lex

For the
> meantime, I changed the function name to utils_is_file_writable()
> hoping this is more correct.
>
> Regards,
> Enrico
>
> --
> Get my GPG key from http://www.uvena.de/pub.asc
>
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
>
>



More information about the Devel mailing list