Skipping directories containing a .lmsignore file. fix #120
This commit is contained in:
@@ -79,7 +79,7 @@ getLastWriteTime(const std::filesystem::path& file)
|
||||
}
|
||||
|
||||
bool
|
||||
exploreFilesRecursive(const std::filesystem::path& directory, std::function<bool(std::error_code, const std::filesystem::path&)> cb)
|
||||
exploreFilesRecursive(const std::filesystem::path& directory, std::function<bool(std::error_code, const std::filesystem::path&)> cb, const std::filesystem::path& excludeDirFileName)
|
||||
{
|
||||
std::error_code ec;
|
||||
std::filesystem::directory_iterator itPath {directory, std::filesystem::directory_options::follow_directory_symlink, ec};
|
||||
@@ -90,6 +90,17 @@ exploreFilesRecursive(const std::filesystem::path& directory, std::function<bool
|
||||
return true; // try to continue exploring anyway
|
||||
}
|
||||
|
||||
if (!excludeDirFileName.empty())
|
||||
{
|
||||
const std::filesystem::path excludePath {directory / excludeDirFileName};
|
||||
|
||||
if (std::filesystem::exists(excludePath, ec))
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Found '" << excludePath.string() << "': skipping directory";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::filesystem::directory_iterator itEnd;
|
||||
while (itPath != itEnd)
|
||||
{
|
||||
@@ -108,7 +119,7 @@ exploreFilesRecursive(const std::filesystem::path& directory, std::function<bool
|
||||
else if (std::filesystem::is_directory(*itPath, ec))
|
||||
{
|
||||
if (!ec)
|
||||
continueExploring = exploreFilesRecursive(*itPath, cb);
|
||||
continueExploring = exploreFilesRecursive(*itPath, cb, excludeDirFileName);
|
||||
else
|
||||
continueExploring = cb(ec, *itPath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user