pyinotify
pyinotify copied to clipboard
Don't scan subdirectory of excluded path
hi, here is the directory structure of '/tmp/site/'
├── data
│ ├── da2
│ │ └── fs
│ └── img1
│ ├── a.jpg
│ ├── b.jpg
│ └── ff
│ └── fd
│ ..
│ .... many many directorys
│
├── data2
│ └── a1
└── data3
└── b1
data
has thousands of subdirectory in it .
I want to monitor /tmp/site/
data2
and data3
except data
e = ['^/tmp/site/data']
# it will be exclude all ,no problem
e = ['^/tmp/site/data$']
''' `data2` and `data3` will be watched ,and it exclude 'data'.
But the subdir of 'data' will be watched too.
'''
e = ['^/tmp/site/data$','^/tmp/site/data/.*']
''' I add another rule `/tmp/site/data/.*`
it's work as i expected ;
'''
vm.add_watch('/tmp/site/', mask, exclude_filter=pyinotify.ExcludeFilter(e))
i read the source class WatchManager
add_watch()
will walk all subdir first (may be take very longtime ),then check if it needs to be excluded.
is it possible that if i exclude data
,subdir of data
wouldn't walk() anymore
then subdir wouldn't be watched.
Makes sense. Do you have tried to create a patch for this yourself by any chance already?