From faf9a72765f163cfc31945886bf917d42249b0a1 Mon Sep 17 00:00:00 2001 From: Michal Zoubek Date: Fri, 3 Mar 2023 08:55:00 +0100 Subject: [PATCH] Fixed inotify ignoring hidden files --- prusa/connect/printer/files.py | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/prusa/connect/printer/files.py b/prusa/connect/printer/files.py index 1e9f2c5..ac1d0e3 100644 --- a/prusa/connect/printer/files.py +++ b/prusa/connect/printer/files.py @@ -718,23 +718,24 @@ def __call__(self, timeout=0): events = self.inotify.read(timeout=timeout) events = self.filter_delete_events(events) for event in events: - parent_dir = self.wds[event.wd] - for storage in self.fs.storage_dict.values(): - if parent_dir.startswith(storage.path_storage): - storage.last_updated = time() - for flag in flags.from_mask(event.mask): - # remove wds that are no longer needed - if flag.name == "IGNORED": - del self.wds[event.wd] - continue - # ignore non watched events - if not self.WATCH_FLAGS & flag: - log.debug("Ignoring %s", flag.name) - continue - - abs_path = path.join(parent_dir, event.name) - # Ignore hidden files . - if not event.name.startswith("."): + # Ignore hidden files . + if not event.name.startswith("."): + parent_dir = self.wds[event.wd] + for storage in self.fs.storage_dict.values(): + if parent_dir.startswith(storage.path_storage): + storage.last_updated = time() + for flag in flags.from_mask(event.mask): + # remove wds that are no longer needed + if flag.name == "IGNORED": + del self.wds[event.wd] + continue + # ignore non watched events + if not self.WATCH_FLAGS & flag: + log.debug("Ignoring %s", flag.name) + continue + + abs_path = path.join(parent_dir, event.name) + log.debug("Flag: %s %s %s", flag.name, abs_path, event) handler = self.HANDLERS[flag.name] log.debug("Calling %s: %s", handler, abs_path)