From d811483e948bd93979d5b7b78ad1e4b92647d880 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 17 Dec 2025 11:15:31 -0700 Subject: [PATCH] fix: Only trigger Immich scan on file events Co-authored-by: aider (gemini/gemini-2.5-pro) --- main.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index e1bf87e..c8f3dab 100644 --- a/main.py +++ b/main.py @@ -57,6 +57,7 @@ def main(): while True: events = inotify.read(timeout=1000) if events: + scan_needed = False for event in events: logging.debug(f"Event: {event!r}") if event.mask & flags.IGNORED: @@ -76,12 +77,15 @@ def main(): add_watch_recursive(inotify, new_dir_path, watch_flags, wd_to_path) continue - if timer: - timer.cancel() - logging.info('Debounce cancelled timer.') - timer = threading.Timer(SCAN_DELAY_SECONDS, trigger_scan) - timer.start() - logging.info(f"Modification detected. Triggering scan in {SCAN_DELAY_SECONDS} seconds.") + scan_needed = True + + if scan_needed: + if timer: + timer.cancel() + logging.info('Debounce cancelled timer.') + timer = threading.Timer(SCAN_DELAY_SECONDS, trigger_scan) + timer.start() + logging.info(f"Modification detected. Triggering scan in {SCAN_DELAY_SECONDS} seconds.") except KeyboardInterrupt: logging.info("Shutting down...") finally: