Comments (11)
+1 I have the same problems on my ubuntu laptop.
from watchdog.
The exception raised when the move is from outside the monitored directory to the monitored directory is because the inotify observer assumes there was a MOVE_FROM inotify event, and tries to get source path from it.
I've got a branch modifying the observer to use None sa the src_path in such cases, instead of raising an exception. I've issued a pull request for it: #49
The other issue, missing move events when files are moved OUTSIDE the monitored directories, is IMHO much harder to solve. The way the code works is by first caching the MOVE_FROM inotify event (as described above), and then acting when MOVE_TO inotify event occurs. Since the MOVE_TO event never occurs because the target directory is not monitored, the observer doesn't register that the move has happened.
from watchdog.
I've merged the pull request into HEAD.
Cheers!
from watchdog.
If the issue has been resolved for you, you may
close this issue. =)
from watchdog.
Have both sub-issues been fixed? Senko's comment made it sound as if moving files into a watched directory is fixed, but not moving files out of a watched directory. I'm interested in both cases...
Thanks for the great project, btw.
from watchdog.
I'm not sure that it CAN be fixed reliably. One hack would be to remember MOVE_FROM events, and for each check (after some delay) whether a corresponding MOVE_TO event happened. If not, it's an out move. But I don't especially like this solution, feels hackish (in a negative way) to me.
from watchdog.
So PollingObserver is better in this regard than InotifyObserver. Maybe it will be good to have some SimpleInotifyObserver, that would handle moves as create/delete combos. PollingObserver is good enough for me, so from watchdog.observers.polling import PollingObserver as Observer
does the trick for now
from watchdog.
With this zentyal@9bd7030 you will have events when you move files or directories outside the watched path.
The problem is that for directories (with recursive=True) there should be 'n' events, one per file inside it, that's not possible (afaik) because we don't know the destiny. So in the end this is only a partial workaround, and your application code must know about this issue when using InotifyObserver.
from watchdog.
@blaxter that only works if the from/to pairs happens to be in the same buffer when read. Do a batch move inside a watched tree and it'll probably fire duplicate events.
from watchdog.
I've made an attempt at implementing the much talked about buffer approach. Basically all events are delayed and move from/to pairs matched during this delay. It's not pretty but appears to work ok. Current delay is set to 0.5 seconds (can be changed in inotify_buffered.py
). Checkout branch delayed-inotify
from watchdog.
fixed
from watchdog.
Related Issues (20)
- Inconsistent Triggering of on_created Event HOT 4
- On_moved not able to detect moved file/folder on certain path.
- Version 1.0.2 is not available in PyPi HOT 2
- failure to build on macos with `-Werror=unguarded-availability-new` HOT 4
- Installation fails with 4.0.0 HOT 25
- Unable to find installation candidates on v4.0.0 HOT 6
- silently fails if path is file HOT 7
- types: Types checks reporting issues after updating watchdog to 3.0.0. Same issue with 4.0.0 HOT 8
- Questions about Copilot + Open Source Software Hierarchy
- [Question] Is it possible to execute manuall poll?
- Is it possible to prevent being connected to named pipe on Windows platform?
- [Feature] Allow adding `ObservedWatch` without handlers
- Improve typing references for events
- Moved file memory leak
- [Question] is watchdog support s3fs-fuse mount aws s3 bucket to file system directory monitor
- Feature Request: Allow functions as event handlers
- Race condition in Observer.start() and observer.schedule() HOT 1
- Threads not cleaning up when closing Observer if using Eventlet. HOT 1
- Ambiguity in setting FileClosedEvent in filter HOT 5
- class FSEventsObserver.schedule() is missing parameter 'event_filter'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from watchdog.