From 068cd559e11dd5b95229d4e18710dffe27fa9ae9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 22 May 2023 15:41:20 +0200 Subject: [PATCH] db/update/Walk: clear `Song::in_playlist` Without clearing all `in_playlist` flags, the songs will never be revealed again if they were hidden once by a CUE sheet, not even after the CUE sheet gets deleted or modified. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1784 --- NEWS | 2 ++ src/db/plugins/simple/Directory.cxx | 12 ++++++++++++ src/db/plugins/simple/Directory.hxx | 8 ++++++++ src/db/update/Walk.cxx | 1 + 4 files changed, 23 insertions(+) diff --git a/NEWS b/NEWS index 69d88b777..cd9636d6f 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ ver 0.23.13 (not yet released) - curl: fix busy loop after connection failed * archive - zzip: fix crash bug +* database + - simple: reveal hidden songs after deleting containing CUE * decoder - ffmpeg: reorder to a lower priority than "gme" - gme: require GME 0.6 or later diff --git a/src/db/plugins/simple/Directory.cxx b/src/db/plugins/simple/Directory.cxx index 313709a31..f00215355 100644 --- a/src/db/plugins/simple/Directory.cxx +++ b/src/db/plugins/simple/Directory.cxx @@ -126,6 +126,18 @@ Directory::LookupTargetSong(std::string_view _target) noexcept return lr.directory->FindSong(lr.rest); } +void +Directory::ClearInPlaylist() noexcept +{ + assert(holding_db_lock()); + + for (auto &child : children) + child.ClearInPlaylist(); + + for (auto &song : songs) + song.in_playlist = false; +} + void Directory::PruneEmpty() noexcept { diff --git a/src/db/plugins/simple/Directory.hxx b/src/db/plugins/simple/Directory.hxx index e13b556ff..3b4b280fe 100644 --- a/src/db/plugins/simple/Directory.hxx +++ b/src/db/plugins/simple/Directory.hxx @@ -287,6 +287,14 @@ public: */ SongPtr RemoveSong(Song *song) noexcept; + /** + * Recursively walk through the whole tree and set all + * `Song::in_playlist` fields to `false`. + * + * Caller must lock the #db_mutex. + */ + void ClearInPlaylist() noexcept; + /** * Caller must lock the #db_mutex. */ diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index be71e7195..4fdec28d9 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -531,6 +531,7 @@ UpdateWalk::Walk(Directory &root, const char *path, bool discard) noexcept { const ScopeDatabaseLock protect; + root.ClearInPlaylist(); PurgeDanglingFromPlaylists(root); }