Avoid reloading IDE on inotify events from the previous write

This commit is contained in:
Kristóf Tóth 2019-09-27 15:16:08 +02:00
parent ed4fdb92a5
commit 086df3700d

View File

@ -39,6 +39,7 @@ class IdeHandler:
self.connector = None self.connector = None
self.filemanager = FileManager(patterns) self.filemanager = FileManager(patterns)
self._initial_file = initial_file or '' self._initial_file = initial_file or ''
self._ignore_inotify_src = ''
self.monitor = InotifyObserver( self.monitor = InotifyObserver(
path=self.filemanager.parents, path=self.filemanager.parents,
@ -53,6 +54,9 @@ class IdeHandler:
} }
def _reload_frontend(self, event): # pylint: disable=unused-argument def _reload_frontend(self, event): # pylint: disable=unused-argument
if self._ignore_inotify_src == event.src_path:
self._ignore_inotify_src = ''
return
self.send_message({'key': 'ide.reload'}) self.send_message({'key': 'ide.reload'})
@property @property
@ -90,6 +94,7 @@ class IdeHandler:
def write(self, message): def write(self, message):
try: try:
self._ignore_inotify_src = message['filename']
self.filemanager.write_file(message['filename'], message['content']) self.filemanager.write_file(message['filename'], message['content'])
except KeyError: except KeyError:
LOG.error('You must provide a filename to write!') LOG.error('You must provide a filename to write!')