From 363d9f0180a9a3e201e1ce354f9a484b1a431215 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 25 May 2021 22:35:18 +0200 Subject: [PATCH] db/update/Walk: load all .mpdignore files of all parent directories When updating everything, this did work, but if updating only a subdirectory, the ".mpdignore" in the parents were not used. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1172 --- NEWS | 2 ++ src/db/update/Walk.cxx | 27 ++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 9883f913b..b3972e557 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.22.9 (not yet released) +* database + - simple: load all .mpdignore files of all parent directories * Windows - fix build failure with SQLite diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index 1c01934d6..b1fb675e6 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -458,6 +458,28 @@ UpdateWalk::DirectoryMakeUriParentChecked(Directory &root, return directory; } +static void +LoadExcludeLists(std::forward_list &lists, + const Storage &storage, const Directory &directory) noexcept +{ + assert(!lists.empty()); + + if (!directory.IsRoot()) + LoadExcludeLists(lists, storage, *directory.parent); + + lists.emplace_front(); + LoadExcludeListOrLog(storage, directory, lists.front()); +} + +static auto +LoadExcludeLists(const Storage &storage, const Directory &directory) noexcept +{ + std::forward_list lists; + lists.emplace_front(); + LoadExcludeLists(lists, storage, directory); + return lists; +} + inline void UpdateWalk::UpdateUri(Directory &root, const char *uri) noexcept try { @@ -478,9 +500,8 @@ try { return; } - ExcludeList exclude_list; - - UpdateDirectoryChild(*parent, exclude_list, name, info); + const auto exclude_lists = LoadExcludeLists(storage, *parent); + UpdateDirectoryChild(*parent, exclude_lists.front(), name, info); } catch (...) { LogError(std::current_exception()); }