mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 07:01:33 +00:00
Avoid reloading IDE on inotify events from the previous write
This commit is contained in:
parent
ed4fdb92a5
commit
086df3700d
@ -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!')
|
||||||
|
Loading…
Reference in New Issue
Block a user