[Github-comments] [geany/geany] Make document_rename_file() return a gboolean; Abort save if rename fails (#1180)

konsolebox notifications at xxxxx
Fri Aug 19 10:29:44 UTC 2016


Here's a patch.  It was pretty easy to make: https://github.com/konsolebox/geany/commit/e329b289df38442b96d2b9add6586b2c3ed02c1b

I can create a PR if it's really wanted.

> ... separating rename and save is a better idea still.

In the context of stand-alone renaming yes, but if it's about a document not, because like I said every caller would make sure that all necessary listeners to "document-save" would get notified about the change.  I'm not sure if it makes sense to have the GeanyDocument stay as is while the name of the file in the filesystem gets changed.  I don't say any use case for it.  Not to mention `document_rename_file()` already calls `document_stop_file_monitoring()` and it expects `document_save_file_as()` to be called after.  We wouldn't want plugins (or anything that calls `document_rename_file()`) to always do both sequences separately.

... Ok, maybe since nothing is really changed in GeanyDocument when a file is renamed, notifying listeners to "document-save" may not be necessary (until the save operation actually starts), but both operations are still better put together in a single API function due to the fact that `document_rename_file()` can't be used alone in one operating session.

Here's a gist for the function: https://gist.github.com/konsolebox/b95bd34e518ac1d1aa60a6348bd498b9

There are surprising things about `doc->priv->file_disk_status` but I haven't looked into it thoroughly yet.  Basically the idea is that `document_save_file_as()` does not revert `doc->priv->file_disk_status` to its original state if the save fails.  And so does `document_rename_file()`.  Simply because it can't, because it's used separately from `document_save_file_as()`.

-- 
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/1180#issuecomment-240984242
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160819/adeacb9e/attachment.html>


More information about the Github-comments mailing list