monitors: Renaming a directory sometimes produces a DELETE event instead of a MOVED_FROM / MOVED_TO pair
This leads to intermittent test failures in tracker-monitor-test which have been plaguing us for years.
tracker#20 (closed) tried to fix this issue but it's still present.
Here's a log taken while I worked on !187 (merged)
# Tracker-DEBUG: ***** '/tmp/tracker-monitor-test-481IJ0/directory/file.txt' (FILE) (CREATED)
# Tracker-DEBUG: ***** '/tmp/tracker-monitor-test-481IJ0/directory/file.txt' (FILE) (UPDATED)
# Tracker-DEBUG: ***** '/tmp/tracker-monitor-test-481IJ0/directory' (DIR) (DELETED)
# Tracker-MESSAGE: Prohibited event received for 'file:///tmp/tracker-monitor-test-481IJ0/directory':
CREATED: no (prohibited)
UPDATED: no (prohibited)
ATTRIBUTE UPDATED: no (prohibited)
DELETED: yes (prohibited)
MOVED_FROM: no
MOVED_TO: no (prohibited)
not ok 12 /libtracker-miner/tracker-monitor/directory-event/moved/to-monitored-after-file-create
9 times out of 10, the monitoring works fine and we receive a MOVED_FROM/MOVED_TO pair. It's not clear what goes wrong that we sometimes receive DELETED instead.
Using TRACKER_DEBUG=monitors
I got this log:
# Tracker-MESSAGE: Received monitor event:0 (G_FILE_MONITOR_EVENT_CHANGED) for file:'file:///tmp/tracker-monitor-test-AIATJ0/directory/file.txt'
# Tracker-MESSAGE: Received monitor event:1 (G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT) for file:'file:///tmp/tracker-monitor-test-AIATJ0/directory/file.txt'
# Tracker-DEBUG: ***** '/tmp/tracker-monitor-test-AIATJ0/directory/file.txt' (FILE) (UPDATED)
# Tracker-MESSAGE: Received monitor event:2 (G_FILE_MONITOR_EVENT_DELETED) for directory:'file:///tmp/tracker-monitor-test-AIATJ0/directory'
# Tracker-MESSAGE: Cancelled monitor for path:'file:///tmp/tracker-monitor-test-AIATJ0/directory'
So it seems we are getting DELETED from Gio in the failure case.
In the success case we see this in the log:
# Tracker-MESSAGE: Received monitor event:8 (G_FILE_MONITOR_EVENT_RENAMED) for files 'file:///tmp/tracker-monitor-test-JW0PJ0/directory'->'file:///tmp/tracker-monitor-test-JW0PJ0/renamed'
# Tracker-MESSAGE: Cancelled monitor for path:'file:///tmp/tracker-monitor-test-JW0PJ0/directory'
Edited by Sam Thursfield