inotify.c directory removal fails to remove empty child containers
Brought to you by:
jmaggard
The inotify_remove_directory() function lacks the children code in inotify_remove_file(). As a result, there will be different results with empty object containers depending on which function is used.
One way to fix this is to call inotify_remove_file() in inotify_remove_directory(). Then, in inotify_remove_file(), add some additional code to protect "static" containers.
This issue still exists after commit [50b1a2]. It is preventing inotify and rescan features from removing all related metadata containers.
To reproduce, remove a directory containing tagged music files with the only artist/album in the database. The (now renamed) function monitor_remove_directory() will fail to remove the empty metadata based containers.
Related
Commit: [50b1a2]
Additional info: The two commands below will produce different database results due to inotify sending file events for rm and a directory event for mv. media_dir=/media.
Working example. I used this free download with tagged mp3's.
Unzip file to a directory.
Remove 'rm' results.
Move 'mv' results.
Diff results.
diff rm.txt mv.txt 92a93,96 > 132|1$7$1|1$7||container.album.musicAlbum|50|Demo 2011 > 134|1$6$1|1$6||container.person.musicArtist|51|The Great Divide > 135|1$6$1$0|1$6$1||container.album|52|- All Albums - > 136|1$6$1$1|1$6$1|1$7$1|container.album.musicAlbum|50|Demo 2011
Even though the directory was removed from the media_dir by both commands, the move command left behind empty metadata based containers due to inotify sending a directory event instead of a file event.
NOTE: The above test media_dir contained another directory with a different band and album.