dsoprea / PyInotify

An efficient and elegant inotify (Linux filesystem activity monitor) library for Python. Python 2 and 3 compatible.
GNU General Public License v2.0
245 stars 73 forks source link

Moving a previously removed folder crashing #46

Open Jvlythical opened 6 years ago

Jvlythical commented 6 years ago

Error

Traceback (most recent call last):
  File "../test.py", line 20, in <module>
    _main()
  File "../test.py", line 11, in _main
    for event in i.event_gen(yield_nones=False):
  File "/home/jvlarble/.local/lib/python3.6/site-packages/inotify/adapters.py", line 307, in event_gen
    self._i.remove_watch(full_path, superficial=True)
  File "/home/jvlarble/.local/lib/python3.6/site-packages/inotify/adapters.py", line 118, in remove_watch
    self.remove_watch_with_id(wd)
  File "/home/jvlarble/.local/lib/python3.6/site-packages/inotify/adapters.py", line 126, in remove_watch_with_id
    inotify.calls.inotify_rm_watch(self.__inotify_fd, wd)
  File "/home/jvlarble/.local/lib/python3.6/site-packages/inotify/calls.py", line 35, in _check_nonnegative
    (result,))
inotify.calls.InotifyError: Call failed (should not be -1): (-1) ERRNO=(0)

Source

import inotify.adapters

def _main():
    i = inotify.adapters.InotifyTree('.')

    #i.add_watch('.')

    #with open('/tmp/test_file', 'w'):
    #    pass

    for event in i.event_gen(yield_nones=False):
        (_, type_names, path, filename) = event

        print("PATH=[{}] FILENAME=[{}] EVENT_TYPES={}".format(
              path, filename, type_names))

if __name__ == '__main__':
    _main()

Steps to reproduce:

mkdir a  
rmdir a  
mkdir a  
mv a b