diff --git a/frontends/src/jp/cmd_blog.py b/frontends/src/jp/cmd_blog.py index 9421ff86..569f7a6f 100644 --- a/frontends/src/jp/cmd_blog.py +++ b/frontends/src/jp/cmd_blog.py @@ -445,16 +445,23 @@ class Preview(base.CommandBase, BlogCommon): 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: