diff --git a/lib/tfw/components/history_monitor.py b/lib/tfw/components/history_monitor.py index 395149d..f07a57b 100644 --- a/lib/tfw/components/history_monitor.py +++ b/lib/tfw/components/history_monitor.py @@ -1,11 +1,11 @@ from watchdog.observers import Observer -from watchdog.events import FileSystemEventHandler +from watchdog.events import PatternMatchingEventHandler from os.path import dirname -class CallbackEventHandler(FileSystemEventHandler): - def __init__(self, *callbacks): - super().__init__() +class CallbackEventHandler(PatternMatchingEventHandler): + def __init__(self, files, *callbacks): + super().__init__(files) self.callbacks = callbacks def on_modified(self, event): @@ -20,7 +20,8 @@ class HistoryMonitor: self._last_length = len(self._history) self._callbacks = [] self.observer = Observer() - self.observer.schedule(CallbackEventHandler(self._fetch_history, + self.observer.schedule(CallbackEventHandler([self.histfile], + self._fetch_history, self._invoke_callbacks), dirname(self.histfile))