diff options
author | Max Kellermann <max@musicpd.org> | 2021-05-25 22:37:26 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2021-05-25 22:38:01 +0200 |
commit | db0682a469cbf6303bbb96e770a7b6fd1a485d05 (patch) | |
tree | 8f8c202fb9dc77a9a9cd4f0f7fde8c336677f56c | |
parent | 7a6823dcdfc7056d3c0e93f31aea49a99a2fddd9 (diff) |
db/update/Walk: move code to LoadExcludeList()
-rw-r--r-- | src/db/update/Walk.cxx | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index 6391ed445..1c01934d6 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -312,6 +312,29 @@ UpdateWalk::SkipSymlink(const Directory *directory, #endif } +static void +LoadExcludeListOrThrow(const Storage &storage, const Directory &directory, + ExcludeList &exclude_list) +{ + Mutex mutex; + auto is = InputStream::OpenReady(storage.MapUTF8(PathTraitsUTF8::Build(directory.GetPath(), + ".mpdignore")).c_str(), + mutex); + exclude_list.Load(std::move(is)); +} + +static void +LoadExcludeListOrLog(const Storage &storage, const Directory &directory, + ExcludeList &exclude_list) noexcept +{ + try { + LoadExcludeListOrThrow(storage, directory, exclude_list); + } catch (...) { + if (!IsFileNotFound(std::current_exception())) + LogError(std::current_exception()); + } +} + bool UpdateWalk::UpdateDirectory(Directory &directory, const ExcludeList &exclude_list, @@ -331,17 +354,7 @@ UpdateWalk::UpdateDirectory(Directory &directory, } ExcludeList child_exclude_list(exclude_list); - - try { - Mutex mutex; - auto is = InputStream::OpenReady(storage.MapUTF8(PathTraitsUTF8::Build(directory.GetPath(), - ".mpdignore")).c_str(), - mutex); - child_exclude_list.Load(std::move(is)); - } catch (...) { - if (!IsFileNotFound(std::current_exception())) - LogError(std::current_exception()); - } + LoadExcludeListOrLog(storage, directory, child_exclude_list); if (!child_exclude_list.IsEmpty()) RemoveExcludedFromDirectory(directory, child_exclude_list); |