db/update/playlist: remove non-existent targets while scanning

This commit is contained in:
Max Kellermann 2021-10-13 19:10:20 +02:00
parent 1bbe9896f6
commit 9200fa6d06
1 changed files with 8 additions and 2 deletions

View File

@ -72,8 +72,9 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
auto db_song = std::make_unique<Song>(std::move(*song),
*directory);
db_song->target =
PathTraitsUTF8::IsAbsoluteOrHasScheme(db_song->filename.c_str())
const bool is_absolute =
PathTraitsUTF8::IsAbsoluteOrHasScheme(db_song->filename.c_str());
db_song->target = is_absolute
? db_song->filename
/* prepend "../" to relative paths to
go from the virtual directory
@ -85,6 +86,11 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
{
const ScopeDatabaseLock protect;
if (!is_absolute &&
!directory->TargetExists(db_song->target))
continue;
directory->AddSong(std::move(db_song));
}
}