db/update/playlist: remove non-existent targets while scanning
This commit is contained in:
parent
1bbe9896f6
commit
9200fa6d06
@ -72,8 +72,9 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
|
|||||||
|
|
||||||
auto db_song = std::make_unique<Song>(std::move(*song),
|
auto db_song = std::make_unique<Song>(std::move(*song),
|
||||||
*directory);
|
*directory);
|
||||||
db_song->target =
|
const bool is_absolute =
|
||||||
PathTraitsUTF8::IsAbsoluteOrHasScheme(db_song->filename.c_str())
|
PathTraitsUTF8::IsAbsoluteOrHasScheme(db_song->filename.c_str());
|
||||||
|
db_song->target = is_absolute
|
||||||
? db_song->filename
|
? db_song->filename
|
||||||
/* prepend "../" to relative paths to
|
/* prepend "../" to relative paths to
|
||||||
go from the virtual directory
|
go from the virtual directory
|
||||||
@ -85,6 +86,11 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
|
|||||||
|
|
||||||
{
|
{
|
||||||
const ScopeDatabaseLock protect;
|
const ScopeDatabaseLock protect;
|
||||||
|
|
||||||
|
if (!is_absolute &&
|
||||||
|
!directory->TargetExists(db_song->target))
|
||||||
|
continue;
|
||||||
|
|
||||||
directory->AddSong(std::move(db_song));
|
directory->AddSong(std::move(db_song));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user