From db0682a469cbf6303bbb96e770a7b6fd1a485d05 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 25 May 2021 22:37:26 +0200 Subject: [PATCH] db/update/Walk: move code to LoadExcludeList() --- src/db/update/Walk.cxx | 35 ++++++++++++++++++++++++----------- 1 file 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);