From e9bc593ba023ad4d4c0aa1f5b6b014e36f631968 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 13 Oct 2023 12:13:42 +0200 Subject: [PATCH] Exclude on_opened and on_closed from watcher events We're not interested in these. `on_opened` in particular was introduced in https://github.com/gorakhargosh/watchdog/pull/941 and then partially reverted in https://github.com/gorakhargosh/watchdog/commit/25a2d1fec55fc32f97055ba827c8ce7b959acb34, but that doesn't work for us. Should fix https://github.com/galaxyproject/galaxy/issues/16840 --- lib/galaxy/util/watcher.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/util/watcher.py b/lib/galaxy/util/watcher.py index 6bfc5861bd38..dd4f0110299a 100644 --- a/lib/galaxy/util/watcher.py +++ b/lib/galaxy/util/watcher.py @@ -130,7 +130,17 @@ class EventHandler(FileSystemEventHandler): def __init__(self, watcher): self.watcher = watcher - def on_any_event(self, event): + # this effectively excludes on_opened and on_closed + def on_moved(self, event): + self._handle(event) + + def on_created(self, event): + self._handle(event) + + def on_deleted(self, event): + self._handle(event) + + def on_modified(self, event): self._handle(event) def _extension_check(self, key, path):