fix: Only trigger Immich scan on file events

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2025-12-17 11:15:31 -07:00
parent a92c0464d2
commit d811483e94

16
main.py
View File

@@ -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: