Menu

#6 Update GIO file monitor handling code to account mtime

open
nobody
None
5
2011-06-30
2011-06-30
Eugene
No

Current code relies on the fact that change hint is sent only once after a file is saved in Geany, which isn't true if g_file_replace_contents() is used for writing the file: at least in GLib 2.26 it causes two notifications. The patch makes additional check of mtime before telling the user a file was updated. [1] is the original discussion

There are two suggestions for the patch, which aren't implemented:
- we can use != instead of < when comparing old and new mtime, so that Geany correctly works with tools that restore mtime [2]
- we can remove FILE_IGNORE constant and just check mtime, thought it will cost us additional check of mtime [3]

[1] http://lists.uvena.de/geany-devel/2010-November/003497.html
[2] http://lists.uvena.de/geany-devel/2010-November/003507.html
[3] http://lists.uvena.de/geany-devel/2010-November/003641.html

Discussion

  • Anonymous

    Anonymous - 2011-06-30

    I wonder if just changing document.c:499 to this would fix the problem?

    doc->priv->monitor = g_file_monitor_file(file, G_FILE_MONITOR_SEND_MOVED, NULL, NULL);

    Then handle a G_FILE_MONITOR_EVENT_MOVED in the callback's switch(event){...}.

    Just a thought, I didn't study the problem much.

     
  • Eugene

    Eugene - 2011-07-02

    Basically, no. SEND_MOVED flag only causes DELETED and CREATED events to be grouped. It leaves intact CHANGES_DONE_HINT events which our code handles. We still get two hints when file is written using g_file_replace_contents().

     
  • Ryan

    Ryan - 2011-08-23

    Just tested this patch on rev 5895 and it worked great for the local file double notification problem.

    The one snag I ran into was for the past while I have been enabling remote monitoring using GIO file monitoring and Geany has been working great. This patch some how interferes with the reloading of remote files. The tab text turns orange but when the document is clicked on it is never asked to reload and the tab text returns to a normal color.

     

Log in to post a comment.