filesaver: count logic was wrong if --continue wasn't given

This commit is contained in:
Albert S. 2019-04-30 23:44:27 +02:00
parent e12d208b5f
commit f97ba49b91

View File

@ -72,7 +72,7 @@ int FileSaver::updateFiles(const QVector<QString> paths, bool keepGoing, bool ve
int FileSaver::processFiles(const QVector<QString> paths, std::function<SaveFileResult(QString path)> saverFunc, bool keepGoing, bool verbose) int FileSaver::processFiles(const QVector<QString> paths, std::function<SaveFileResult(QString path)> saverFunc, bool keepGoing, bool verbose)
{ {
std::atomic<bool> terminate { false }; std::atomic<bool> terminate { false };
std::atomic<int> errorsCount { 0 }; std::atomic<int> processedCount { 0 };
QtConcurrent::blockingMap(paths, [&](const QString &path) { QtConcurrent::blockingMap(paths, [&](const QString &path) {
if(terminate.load()) if(terminate.load())
{ {
@ -85,13 +85,15 @@ int FileSaver::processFiles(const QVector<QString> paths, std::function<SaveFile
SaveFileResult result = saverFunc(path); SaveFileResult result = saverFunc(path);
if(result == DBFAIL || result == PROCESSFAIL) if(result == DBFAIL || result == PROCESSFAIL)
{ {
errorsCount++;
Logger::error() << "Failed to process " << path << endl; Logger::error() << "Failed to process " << path << endl;
if(!keepGoing) if(!keepGoing)
{ {
terminate = true; terminate = true;
} }
} }
else
{
++processedCount;
if(verbose) if(verbose)
{ {
if(result == SKIPPED) if(result == SKIPPED)
@ -103,8 +105,10 @@ int FileSaver::processFiles(const QVector<QString> paths, std::function<SaveFile
Logger::info() << "Added" << path << endl; Logger::info() << "Added" << path << endl;
} }
} }
}
}); });
return paths.size() - errorsCount.load(); return processedCount.load();
} }