Made sure large filesystem changes are handled quickly with one sync_with_filesystem.
This commit is contained in:
parent
74ca3426ff
commit
91879f2041
2 changed files with 16 additions and 18 deletions
5
BUGS
5
BUGS
|
|
@ -5,8 +5,6 @@ Current
|
|||
e.g. vigil.py pylint, BUGS metadata, BUGS _pygments
|
||||
- Scrolling in the help screen doesn't work with the arrow keys.
|
||||
- Within the sandbox sudo is not working for tools.
|
||||
- When the filesystem changes a lot vigil is syncing the summary repeatedly
|
||||
for each part in a queue of changes. Needs to empty the queue then sync.
|
||||
- There is an exception if vigil's window is made too small.
|
||||
|
||||
|
||||
|
|
@ -207,6 +205,9 @@ Fixed
|
|||
pause to stop computation.
|
||||
- Changing the status style with 'watching' off can result in recalculations.
|
||||
<- 'Watching' is never off now
|
||||
- When the filesystem changes a lot vigil is syncing the summary repeatedly
|
||||
for each part in a queue of changes. Needs to empty the queue then sync.
|
||||
|
||||
|
||||
On hold, run-tool related
|
||||
- Sometimes there is a blank line at the end of the result in run-tool, and
|
||||
|
|
|
|||
29
vigil
29
vigil
|
|
@ -834,28 +834,26 @@ class Runner:
|
|||
self.worker.continue_()
|
||||
|
||||
|
||||
def add_watch_manager_to_mainloop(watch_manager, mainloop):
|
||||
notifier = pyinotify.Notifier(watch_manager)
|
||||
|
||||
def on_inotify():
|
||||
notifier.read_events()
|
||||
notifier.process_events()
|
||||
mainloop.add_reader(watch_manager.get_fd(), on_inotify)
|
||||
|
||||
|
||||
def is_path_excluded(path):
|
||||
return any(part.startswith(".") for part in path.split(os.path.sep))
|
||||
|
||||
|
||||
def make_watch_manager(root_path, callback):
|
||||
def add_watch_manager_to_mainloop(root_path, mainloop, on_filesystem_change):
|
||||
watch_manager = pyinotify.WatchManager()
|
||||
event_mask = (pyinotify.IN_CREATE | pyinotify.IN_DELETE |
|
||||
pyinotify.IN_CLOSE_WRITE | pyinotify.IN_ATTRIB |
|
||||
pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO)
|
||||
watch_manager.add_watch(root_path, event_mask, rec=True, auto_add=True,
|
||||
proc_fun=callback, exclude_filter=lambda path:
|
||||
is_path_excluded(path))
|
||||
return watch_manager
|
||||
proc_fun=lambda event: None,
|
||||
exclude_filter=lambda path: is_path_excluded(path))
|
||||
notifier = pyinotify.Notifier(watch_manager)
|
||||
|
||||
def on_inotify():
|
||||
time.sleep(0.1) # A little time for more events
|
||||
notifier.read_events()
|
||||
notifier.process_events()
|
||||
on_filesystem_change()
|
||||
mainloop.add_reader(watch_manager.get_fd(), on_inotify)
|
||||
|
||||
|
||||
_UPDATE_THREAD_STOPPED = False
|
||||
|
|
@ -893,12 +891,11 @@ def main(root_path, is_being_tested=False):
|
|||
log._appearance_changed_event = appearance_changed_event
|
||||
summary.sync_with_filesystem()
|
||||
|
||||
def on_filesystem_change(event):
|
||||
def on_filesystem_change():
|
||||
log.log_message("Filesystem changed.")
|
||||
summary.sync_with_filesystem(sync_tools=False)
|
||||
appearance_changed_event.set()
|
||||
watch_manager = make_watch_manager(root_path, on_filesystem_change)
|
||||
add_watch_manager_to_mainloop(watch_manager, loop)
|
||||
add_watch_manager_to_mainloop(root_path, loop, on_filesystem_change)
|
||||
log.log_message("Program started.")
|
||||
jobs_added_event.set()
|
||||
runners = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue