Compare commits

...

3 Commits

Author SHA1 Message Date
79bf32b35c Adjust log message 2026-04-24 10:28:36 -06:00
2eb104f4c3 fix: Reduce log spam for missing watch paths
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
2026-04-24 10:25:58 -06:00
941fb535f6 fix: Make watch setup resilient to unmounted paths
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
2026-04-24 10:20:15 -06:00

22
main.py
View File

@@ -31,7 +31,7 @@ def trigger_scan():
def add_watch_recursive(inotify, path, watch_flags, wd_to_path):
"""Walk a directory path and add watches recursively."""
try:
logging.info(f"Watching {path} and its subdirectories recursively.")
for root, _, _ in os.walk(path):
try:
logging.info(f"Watching {root}")
@@ -39,22 +39,30 @@ def add_watch_recursive(inotify, path, watch_flags, wd_to_path):
wd_to_path[wd] = root
except OSError as e:
logging.error(f"Error adding watch for {root}: {e}")
except FileNotFoundError:
logging.warning(f"Could not scan {path} as it was not found.")
def main():
global timer
watch_flags = flags.MODIFY | flags.CREATE | flags.DELETE | flags.MOVED_FROM | flags.MOVED_TO
wd_to_path = {}
missing_paths = set()
with INotify() as inotify:
for path in secrets.WATCH_PATHS:
logging.info(f"Watching {path} and its subdirectories recursively.")
add_watch_recursive(inotify, path, watch_flags, wd_to_path)
try:
while True:
watched_dirs = set(wd_to_path.values())
for path in secrets.WATCH_PATHS:
if path not in watched_dirs:
if os.path.exists(path):
if path in missing_paths:
logging.info(f"Watch path {path} is now available.")
missing_paths.remove(path)
add_watch_recursive(inotify, path, watch_flags, wd_to_path)
else:
if path not in missing_paths:
logging.warning(f"Watch path {path} does not exist. Re-checking every second...")
missing_paths.add(path)
events = inotify.read(timeout=1000)
if events:
scan_needed = False