db/update/Walk: move PurgeDanglingFromPlaylists() to Playlist.cxx

This commit is contained in:
Max Kellermann 2021-10-14 13:12:00 +02:00
parent b82b56970b
commit f7622ca332
2 changed files with 22 additions and 22 deletions

View File

@ -126,3 +126,25 @@ UpdateWalk::UpdatePlaylistFile(Directory &directory,
return true; return true;
} }
void
UpdateWalk::PurgeDanglingFromPlaylists(Directory &directory) noexcept
{
/* recurse */
for (Directory &child : directory.children)
PurgeDanglingFromPlaylists(child);
if (!directory.IsPlaylist())
/* this check is only for virtual directories
representing a playlist file */
return;
directory.ForEachSongSafe([&](Song &song){
if (!song.target.empty() &&
!PathTraitsUTF8::IsAbsoluteOrHasScheme(song.target.c_str()) &&
!directory.TargetExists(song.target)) {
editor.DeleteSong(directory, &song);
modified = true;
}
});
}

View File

@ -132,28 +132,6 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept
} }
} }
void
UpdateWalk::PurgeDanglingFromPlaylists(Directory &directory) noexcept
{
/* recurse */
for (Directory &child : directory.children)
PurgeDanglingFromPlaylists(child);
if (!directory.IsPlaylist())
/* this check is only for virtual directories
representing a playlist file */
return;
directory.ForEachSongSafe([&](Song &song){
if (!song.target.empty() &&
!PathTraitsUTF8::IsAbsoluteOrHasScheme(song.target.c_str()) &&
!directory.TargetExists(song.target)) {
editor.DeleteSong(directory, &song);
modified = true;
}
});
}
#ifndef _WIN32 #ifndef _WIN32
static bool static bool
update_directory_stat(Storage &storage, Directory &directory) noexcept update_directory_stat(Storage &storage, Directory &directory) noexcept