fix: Resolve AttributeError and clean up ignored watch descriptors
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
9
main.py
9
main.py
@@ -59,12 +59,19 @@ def main():
|
|||||||
if events:
|
if events:
|
||||||
for event in events:
|
for event in events:
|
||||||
logging.debug(f"Event: {event!r}")
|
logging.debug(f"Event: {event!r}")
|
||||||
|
if event.mask & flags.IGNORED:
|
||||||
|
logging.info(f"Watch for wd {event.wd} was removed (directory deleted?).")
|
||||||
|
if event.wd in wd_to_path:
|
||||||
|
logging.info(f"Removing path '{wd_to_path[event.wd]}' from watch mapping.")
|
||||||
|
del wd_to_path[event.wd]
|
||||||
|
continue
|
||||||
|
|
||||||
if event.mask & flags.ISDIR and (event.mask & flags.CREATE or event.mask & flags.MOVED_TO):
|
if event.mask & flags.ISDIR and (event.mask & flags.CREATE or event.mask & flags.MOVED_TO):
|
||||||
parent_dir_path = wd_to_path.get(event.wd)
|
parent_dir_path = wd_to_path.get(event.wd)
|
||||||
if not parent_dir_path:
|
if not parent_dir_path:
|
||||||
logging.warning(f"Could not find path for watch descriptor {event.wd}")
|
logging.warning(f"Could not find path for watch descriptor {event.wd}")
|
||||||
continue
|
continue
|
||||||
new_dir_path = os.path.join(parent_dir_path, event.name.decode('utf-8'))
|
new_dir_path = os.path.join(parent_dir_path, event.name)
|
||||||
logging.info(f"New directory {new_dir_path} detected, adding watches.")
|
logging.info(f"New directory {new_dir_path} detected, adding watches.")
|
||||||
add_watch_recursive(inotify, new_dir_path, watch_flags, wd_to_path)
|
add_watch_recursive(inotify, new_dir_path, watch_flags, wd_to_path)
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user