diff --git a/src/db/update/ExcludeList.cxx b/src/db/update/ExcludeList.cxx index 8f37d09f5..332e4bbc7 100644 --- a/src/db/update/ExcludeList.cxx +++ b/src/db/update/ExcludeList.cxx @@ -26,8 +26,8 @@ #include "ExcludeList.hxx" #include "fs/Path.hxx" #include "fs/NarrowPath.hxx" -#include "fs/io/TextFile.hxx" -#include "system/Error.hxx" +#include "input/TextInputStream.hxx" +#include "util/StringUtil.hxx" #include "Log.hxx" #include @@ -44,13 +44,13 @@ ExcludeList::ParseLine(char *line) noexcept } bool -ExcludeList::LoadFile(Path path_fs) noexcept -try { +ExcludeList::Load(InputStreamPtr is) +{ #ifdef HAVE_CLASS_GLOB - TextFile file(path_fs); + TextInputStream tis(std::move(is)); char *line; - while ((line = file.ReadLine()) != nullptr) + while ((line = tis.ReadLine()) != nullptr) ParseLine(line); #else /* not implemented */ @@ -58,13 +58,6 @@ try { #endif return true; -} catch (const std::system_error &e) { - if (!IsFileNotFound(e)) - LogError(e); - return false; -} catch (const std::exception &e) { - LogError(e); - return false; } bool diff --git a/src/db/update/ExcludeList.hxx b/src/db/update/ExcludeList.hxx index d27f1c888..4a851a7dc 100644 --- a/src/db/update/ExcludeList.hxx +++ b/src/db/update/ExcludeList.hxx @@ -28,6 +28,7 @@ #include "check.h" #include "Compiler.h" #include "fs/Glob.hxx" +#include "input/Ptr.hxx" #ifdef HAVE_CLASS_GLOB #include @@ -62,7 +63,7 @@ public: /** * Loads and parses a .mpdignore file. */ - bool LoadFile(Path path_fs) noexcept; + bool Load(InputStreamPtr is); /** * Checks whether one of the patterns in the .mpdignore file matches diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index 8e58f126d..c71b3d73c 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -36,6 +36,9 @@ #include "fs/Traits.hxx" #include "fs/FileSystem.hxx" #include "storage/FileInfo.hxx" +#include "input/InputStream.hxx" +#include "input/Error.hxx" +#include "thread/Cond.hxx" #include "util/Alloc.hxx" #include "util/StringCompare.hxx" #include "util/UriUtil.hxx" @@ -345,11 +348,16 @@ UpdateWalk::UpdateDirectory(Directory &directory, ExcludeList child_exclude_list(exclude_list); - { - const auto exclude_path_fs = - storage.MapChildFS(directory.GetPath(), ".mpdignore"); - if (!exclude_path_fs.IsNull()) - child_exclude_list.LoadFile(exclude_path_fs); + try { + Mutex mutex; + Cond cond; + auto is = InputStream::OpenReady(PathTraitsUTF8::Build(storage.MapUTF8(directory.GetPath()).c_str(), + ".mpdignore").c_str(), + mutex, cond); + child_exclude_list.Load(std::move(is)); + } catch (...) { + if (!IsFileNotFound(std::current_exception())) + LogError(std::current_exception()); } if (!child_exclude_list.IsEmpty())