db/simple: purge songs for unavailable decoder plugins on update
This commit is contained in:
@@ -34,6 +34,14 @@ Song::Song(DetachedSong &&other, Directory &_parent) noexcept
|
||||
{
|
||||
}
|
||||
|
||||
const char *
|
||||
Song::GetFilenameSuffix() const noexcept
|
||||
{
|
||||
return target.empty()
|
||||
? PathTraitsUTF8::GetFilenameSuffix(filename.c_str())
|
||||
: PathTraitsUTF8::GetPathSuffix(target.c_str());
|
||||
}
|
||||
|
||||
std::string
|
||||
Song::GetURI() const noexcept
|
||||
{
|
||||
|
@@ -108,6 +108,16 @@ struct Song {
|
||||
|
||||
Song(DetachedSong &&other, Directory &_parent) noexcept;
|
||||
|
||||
gcc_pure
|
||||
const char *GetFilenameSuffix() const noexcept;
|
||||
|
||||
/**
|
||||
* Checks whether the decoder plugin for this song is
|
||||
* available.
|
||||
*/
|
||||
gcc_pure
|
||||
bool IsPluginAvailable() const noexcept;
|
||||
|
||||
/**
|
||||
* allocate a new song structure with a local file name and attempt to
|
||||
* load its metadata. If all decoder plugin fail to read its meta
|
||||
|
@@ -111,7 +111,11 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept
|
||||
|
||||
directory.ForEachSongSafe([&](Song &song){
|
||||
if (!directory_child_is_regular(storage, directory,
|
||||
song.filename)) {
|
||||
song.filename) ||
|
||||
!song.IsPluginAvailable()) {
|
||||
/* the song file was deleted (or the decoder
|
||||
plugin is unavailable) */
|
||||
|
||||
editor.LockDeleteSong(directory, &song);
|
||||
|
||||
modified = true;
|
||||
|
Reference in New Issue
Block a user