Menu

#285 inotify.c directory removal fails to remove empty child containers

v1.0 (example)
open
nobody
None
5
2017-08-28
2016-02-04
Shrimpkin
No

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.

Discussion

  • Shrimpkin

    Shrimpkin - 2017-08-27

    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]

  • Shrimpkin

    Shrimpkin - 2017-08-28

    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.

    rm -r /media/$DIR
    mv /media/$DIR /tmp/$DIR
    
     
  • Shrimpkin

    Shrimpkin - 2017-08-28

    Working example. I used this free download with tagged mp3's.
    Unzip file to a directory.

    mkdir ~/TheGreatDivide_Demo_2011 && unzip -d ~/TheGreatDivide_Demo_2011 ~/The\ Great\ Divide\ -\ Demo\ 2011.zip
    

    Remove 'rm' results.

    cp -rvp ~/TheGreatDivide_Demo_2011 /media
    rm -r /media/TheGreatDivide_Demo_2011 
    sqlite3 ~/minidlna/files.db "SELECT * FROM objects" > ~/rm.txt
    

    Move 'mv' results.

    cp -rvp ~/TheGreatDivide_Demo_2011 /media
    mv /media/TheGreatDivide_Demo_2011 /tmp
    sqlite3 ~/minidlna/files.db "SELECT * FROM objects" > ~/mv.txt
    

    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.

     

Log in to post a comment.