From f7622ca332f236021c510f4b6b1e09fbf469f56b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 14 Oct 2021 13:12:00 +0200 Subject: [PATCH] db/update/Walk: move PurgeDanglingFromPlaylists() to Playlist.cxx --- src/db/update/Playlist.cxx | 22 ++++++++++++++++++++++ src/db/update/Walk.cxx | 22 ---------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/db/update/Playlist.cxx b/src/db/update/Playlist.cxx index 15573675d..3c3c1aaf9 100644 --- a/src/db/update/Playlist.cxx +++ b/src/db/update/Playlist.cxx @@ -126,3 +126,25 @@ UpdateWalk::UpdatePlaylistFile(Directory &directory, 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; + } + }); +} diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index b544516b9..c4cde3203 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -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 static bool update_directory_stat(Storage &storage, Directory &directory) noexcept