"Clean Library" deletes files on storage instead of just cleaning Kodi database

  • Context: I have two copies of a movie, both files are present on my disk and are catalogued by Kodi library. The files are at the same folder on disk.

    I want to keep just the higher quality copy of the movie, so, I deleted one of the versions. Now, Kodi library must be cleaned to erase the entry for the movie that was deleted from disk.

    What I did: Settings > Media > Library > Clean Library.

    What I expected: Kodi should remove the missing entry from the library database, without ever touching the files on disk.

    What happened: Kodi deletes the entire movie folder for good, including the files I wanted to keep. Kodi erases my files on disk.

    This happened multiple times, and is terrible because it touches the files on disk, when it wasn't supposed to.

    Software/hardware info: LibreELEC 8.2.5, Kodi 17.6, Raspberry Pi 3 B+.

    DEBUG LOGS: check for how it handled the file Thor.Ragnarok.2017.1080p.BluRay.x264-[YTS.AM].cp.mp4
    mg-kodi.log - Pastebin.com

    I have also posted this on Kodi bug tracking:

    #17901 ("Clean Library" deletes files on storage instead of just cleaning Kodi database) – Kodi - TRAC

    • Official Post

    That is not a debug log. A real debug log file is a FULL kodi.log file with debugging enabled, and not edited, redacted or shortened in any way.

    Sorry, but the Clean Library function has no instruction set whatsoever to delete physical files, with or without a user's consent. It only deals with the video and/or music databases.

    Start with providing a proper debug kodi.log file.