Inotify, ubuntu and trash

I ran into an issue while monitoring an ubuntu machine’s file system activity using python’s implementation of Inotify (pyinotify) and it’s awesome big brother, the “watchdog” python library. If you havent checked out watchdog for monitoring file system events – you’re seriously missing out. Catch up on it here:

The watchdog library worked extremely well across all the platforms I tested, including linux ubuntu servers. However I ran into a small issue when testing against an ubuntu client. Watchdog (and pyinotify) was not firing off events when files were being deleted. It turns out ubuntu’s “Trash” system was at fault here. Equivalent to window’s recycle bin, the trash was not actually deleting files when I hit the “delete” button, so there was no event to fire on.

The workaround in my case was to simply remove all permissions on the trash directory by using:

chmod 000 ~/.local/share/Trash

Now when hitting delete, I get asked a confirmation to delete files, and then files are actually removed, firing off the proper delete event in pyinotify and watchdog.


Update : I posted a patch/solution for this problem here:!topic/watchdog-python/t4s1B5IyY4c


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.