db/update/{Walk,ExcludeList}: use InputStream to read .mpdignore
Supports .mpdignore on NFS/SMB and others (closes #290).
This commit is contained in:
parent
86e2075c63
commit
b8259e604a
@ -26,8 +26,8 @@
|
|||||||
#include "ExcludeList.hxx"
|
#include "ExcludeList.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "fs/NarrowPath.hxx"
|
#include "fs/NarrowPath.hxx"
|
||||||
#include "fs/io/TextFile.hxx"
|
#include "input/TextInputStream.hxx"
|
||||||
#include "system/Error.hxx"
|
#include "util/StringUtil.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -44,13 +44,13 @@ ExcludeList::ParseLine(char *line) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ExcludeList::LoadFile(Path path_fs) noexcept
|
ExcludeList::Load(InputStreamPtr is)
|
||||||
try {
|
{
|
||||||
#ifdef HAVE_CLASS_GLOB
|
#ifdef HAVE_CLASS_GLOB
|
||||||
TextFile file(path_fs);
|
TextInputStream tis(std::move(is));
|
||||||
|
|
||||||
char *line;
|
char *line;
|
||||||
while ((line = file.ReadLine()) != nullptr)
|
while ((line = tis.ReadLine()) != nullptr)
|
||||||
ParseLine(line);
|
ParseLine(line);
|
||||||
#else
|
#else
|
||||||
/* not implemented */
|
/* not implemented */
|
||||||
@ -58,13 +58,6 @@ try {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
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
|
bool
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "check.h"
|
#include "check.h"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
#include "fs/Glob.hxx"
|
#include "fs/Glob.hxx"
|
||||||
|
#include "input/Ptr.hxx"
|
||||||
|
|
||||||
#ifdef HAVE_CLASS_GLOB
|
#ifdef HAVE_CLASS_GLOB
|
||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
@ -62,7 +63,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Loads and parses a .mpdignore file.
|
* 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
|
* Checks whether one of the patterns in the .mpdignore file matches
|
||||||
|
@ -36,6 +36,9 @@
|
|||||||
#include "fs/Traits.hxx"
|
#include "fs/Traits.hxx"
|
||||||
#include "fs/FileSystem.hxx"
|
#include "fs/FileSystem.hxx"
|
||||||
#include "storage/FileInfo.hxx"
|
#include "storage/FileInfo.hxx"
|
||||||
|
#include "input/InputStream.hxx"
|
||||||
|
#include "input/Error.hxx"
|
||||||
|
#include "thread/Cond.hxx"
|
||||||
#include "util/Alloc.hxx"
|
#include "util/Alloc.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/UriUtil.hxx"
|
#include "util/UriUtil.hxx"
|
||||||
@ -345,11 +348,16 @@ UpdateWalk::UpdateDirectory(Directory &directory,
|
|||||||
|
|
||||||
ExcludeList child_exclude_list(exclude_list);
|
ExcludeList child_exclude_list(exclude_list);
|
||||||
|
|
||||||
{
|
try {
|
||||||
const auto exclude_path_fs =
|
Mutex mutex;
|
||||||
storage.MapChildFS(directory.GetPath(), ".mpdignore");
|
Cond cond;
|
||||||
if (!exclude_path_fs.IsNull())
|
auto is = InputStream::OpenReady(PathTraitsUTF8::Build(storage.MapUTF8(directory.GetPath()).c_str(),
|
||||||
child_exclude_list.LoadFile(exclude_path_fs);
|
".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())
|
if (!child_exclude_list.IsEmpty())
|
||||||
|
Loading…
Reference in New Issue
Block a user