# HG changeset patch # User Goffi # Date 1457376182 -3600 # Node ID 4f252b72b1936c328e62fc3124ccd78e5e792d1a # Parent 8a5b178ff28b8514a4db7af275612adff20c8a2e jp (blog/preview): change watch for IN_MOVE_SELF event, needed at least for Emacs diff -r 8a5b178ff28b -r 4f252b72b193 frontends/src/jp/cmd_blog.py --- a/frontends/src/jp/cmd_blog.py Mon Mar 07 16:20:41 2016 +0100 +++ b/frontends/src/jp/cmd_blog.py Mon Mar 07 19:43:02 2016 +0100 @@ -445,16 +445,23 @@ def add_watch(): i.add_watch(self.content_file_path, mask=inotify.constants.IN_CLOSE_WRITE | - inotify.constants.IN_DELETE_SELF) + inotify.constants.IN_DELETE_SELF | + inotify.constants.IN_MOVE_SELF) add_watch() try: for event in i.event_gen(): if event is not None: self.disp(u"Content updated", 1) - if "IN_DELETE_SELF" in event[1]: - self.disp(u"IN_DELETE_SELF event catched, changing the watch", 2) - add_watch() + if {"IN_DELETE_SELF", "IN_MOVE_SELF"}.intersection(event[1]): + self.disp(u"{} event catched, changing the watch".format(", ".join(event[1])), 2) + try: + add_watch() + except InotifyError: + # if the new file is not here yet we can have an error + # as a workaround, we do a little rest + time.sleep(1) + add_watch() self.updateContent() update_cb() except InotifyError: