[Github-comments] [geany/geany] Open files without write permission as read only (PR #2989)

elextr notifications at xxxxx
Mon Nov 8 23:22:39 UTC 2021


@xiota sorry for the short response, I was possibly going to be away for a few days but that turns out not to be the case.  I didn't want you to do work unnecessarily before we discuss it.

To me there are two problems with the concept, technical and philosophical.

The philosophical problem is that Geany does not edit files, it edits documents in memory.  There is no reason for the two to match.  Therefore there is nothing linking the state of the document in memory (in this case editability) to the file state (in this case permissions) because Geany has no idea what the user wants to do with their document and is likely to be wrong just as often as right.

And "writable" is not a static state, it can change at any time, for example if permissions change or a network stutters.  That means a state determined at opening can be wrong at any point thereafter.  But it doesn't matter if its wrong because the document in memory is not the file and so shouldn't be linked to the file, except when actual write operations are performed.

But the technical issues are even greater, first I suggest you read my [PHD thesis](https://wiki.geany.org/config/all_you_never_wanted_to_know_about_file_saving) on saving files and note the differing ways Geany can do it.

Not all saving methods depend on the writability of the file, and others depend on more than just that.  For example atomic saving writes a new file and renames it over the old one.  On Linux that needs write permission to the directory, not the existing file.  On windows rename has a number of "interesting" kinks and can fail for other reasons.  So the accuracy of determining if a file is "writable" is not good in any but the simplest case.  And the simplest case isn't the default in Geany.

So not only can "writable" change at any time, but it can't even be determined very well at the initial load file point in time.

As @eht16 has said "who knew it was so hard to write a file" :smile:

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/2989#issuecomment-963665158
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20211108/cee508f2/attachment.htm>


More information about the Github-comments mailing list