Upgrade the library correctly.
1. Clean removed folders in preferences.
2. Clean removed files checking the entire database.
3. Update files changed based on st_mtime (time of last modification) stat().
4. Add new folders added in preferences.