Made scanner abort faster when it has to clean a lot of stuff

This commit is contained in:
emeric
2023-11-14 13:47:08 +01:00
parent 9cfc47fc82
commit b4e515f825
7 changed files with 107 additions and 99 deletions
@@ -23,26 +23,25 @@
namespace Scanner
{
void
ScanStepDiscoverFiles::process(ScanContext& context)
{
context.stats.filesScanned = 0;
PathUtils::exploreFilesRecursive(context.directory, [&](std::error_code ec, const std::filesystem::path& path)
{
if (_abortScan)
return false;
void ScanStepDiscoverFiles::process(ScanContext& context)
{
context.stats.filesScanned = 0;
PathUtils::exploreFilesRecursive(context.directory, [&](std::error_code ec, const std::filesystem::path& path)
{
if (_abortScan)
return false;
if (!ec && PathUtils::hasFileAnyExtension(path, _settings.supportedExtensions))
{
context.currentStepStats.processedElems++;
_progressCallback(context.currentStepStats);
}
if (!ec && PathUtils::hasFileAnyExtension(path, _settings.supportedExtensions))
{
context.currentStepStats.processedElems++;
_progressCallback(context.currentStepStats);
}
return true;
}, &excludeDirFileName);
return true;
}, &excludeDirFileName);
context.stats.filesScanned = context.currentStepStats.processedElems;
context.stats.filesScanned = context.currentStepStats.processedElems;
LMS_LOG(DBUPDATER, DEBUG) << "Discovered " << context.stats.filesScanned << " files in '" << context.directory << "'";
}
LMS_LOG(DBUPDATER, DEBUG) << "Discovered " << context.stats.filesScanned << " files in '" << context.directory << "'";
}
}