Skip to content

Superficial remove prevents later remove #98

@rbiro-alarm

Description

@rbiro-alarm

If you do a superficial remove to invalidate the filename cache, you cannot later stop watching the inode. It would probably be better to just ignore the error.

#!/usr/bin/env python3
import inotify.adapters
import os
from threading import Thread
import time
from inotify.constants import IN_MOVED_FROM, IN_CLOSE_WRITE

i = inotify.adapters.Inotify()

os.system("mkdir foo")
os.system("touch foo/bar")
watch_file = i.add_watch("foo/bar", mask=IN_CLOSE_WRITE)
watch_dir = i.add_watch("foo", IN_MOVED_FROM)

i.remove_watch("foo/bar", superficial=True)
i.remove_watch_with_id(watch_file)

./inotify_test.py
mkdir: cannot create directory ‘foo’: File exists
Traceback (most recent call last):
File "./inotify_test.py", line 16, in
i.remove_watch_with_id(watch_file)
File "/home/rbiro/.local/lib/python3.8/site-packages/inotify/adapters.py", line 121, in remove_watch_with_id
del self.__watches_r[wd]
KeyError: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions