Compare commits
No commits in common. "d23dadbe49e483a3f35fa0d774e653d12858f218" and "9540f27c95c428cafc3a078f2cb0dd1c506bca9f" have entirely different histories.
d23dadbe49
...
9540f27c95
@ -45,7 +45,6 @@ int CommandAdd::handle(QStringList arguments)
|
|||||||
"exit asap, but it's possible that a few files will still be processed. "
|
"exit asap, but it's possible that a few files will still be processed. "
|
||||||
"Set -t 1 to avoid this behavior, but processing will be slower. "},
|
"Set -t 1 to avoid this behavior, but processing will be slower. "},
|
||||||
{{"n", "no-content"}, "Only add paths to database. Do not index content"},
|
{{"n", "no-content"}, "Only add paths to database. Do not index content"},
|
||||||
{{"v", "verbose"}, "Print paths of files being processed"},
|
|
||||||
{{"f", "fill-content"}, "Index content for files previously indexed with -n"},
|
{{"f", "fill-content"}, "Index content for files previously indexed with -n"},
|
||||||
{"tags", "Comma-separated list of tags to assign"},
|
{"tags", "Comma-separated list of tags to assign"},
|
||||||
{{"t", "threads"}, "Number of threads to use.", "threads"}});
|
{{"t", "threads"}, "Number of threads to use.", "threads"}});
|
||||||
@ -57,8 +56,6 @@ int CommandAdd::handle(QStringList arguments)
|
|||||||
this->keepGoing = parser.isSet("continue");
|
this->keepGoing = parser.isSet("continue");
|
||||||
bool pathsOnly = parser.isSet("no-content");
|
bool pathsOnly = parser.isSet("no-content");
|
||||||
bool fillContent = parser.isSet("fill-content");
|
bool fillContent = parser.isSet("fill-content");
|
||||||
bool verbose = parser.isSet("verbose");
|
|
||||||
|
|
||||||
if(parser.isSet("threads"))
|
if(parser.isSet("threads"))
|
||||||
{
|
{
|
||||||
QString threadsCount = parser.value("threads");
|
QString threadsCount = parser.value("threads");
|
||||||
@ -88,44 +85,18 @@ int CommandAdd::handle(QStringList arguments)
|
|||||||
fileSaverOptions.keepGoing = keepGoing;
|
fileSaverOptions.keepGoing = keepGoing;
|
||||||
fileSaverOptions.fillExistingContentless = fillContent;
|
fileSaverOptions.fillExistingContentless = fillContent;
|
||||||
fileSaverOptions.metadataOnly = pathsOnly;
|
fileSaverOptions.metadataOnly = pathsOnly;
|
||||||
fileSaverOptions.verbose = verbose;
|
fileSaverOptions.verbose = false;
|
||||||
|
|
||||||
indexer = new Indexer(*this->dbService);
|
indexer = new Indexer(*this->dbService);
|
||||||
indexer->setFileSaverOptions(fileSaverOptions);
|
indexer->setFileSaverOptions(fileSaverOptions);
|
||||||
|
|
||||||
indexer->setTargetPaths(files.toVector());
|
indexer->setTargetPaths(files.toVector());
|
||||||
|
|
||||||
if(verbose)
|
|
||||||
{
|
|
||||||
indexer->setProgressReportThreshold(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(indexer, &Indexer::pathsCountChanged, this,
|
connect(indexer, &Indexer::pathsCountChanged, this,
|
||||||
[](int pathsCount) { Logger::info() << "Found paths: " << pathsCount << Qt::endl; });
|
[](int pathsCount) { Logger::info() << "Found paths: " << pathsCount << Qt::endl; });
|
||||||
connect(indexer, &Indexer::indexProgress, this,
|
connect(indexer, &Indexer::indexProgress, this,
|
||||||
[verbose, this](int pathsCount, unsigned int /*added*/, unsigned int /*skipped*/, unsigned int /*failed*/,
|
[](int pathsCount, unsigned int /*added*/, unsigned int /*skipped*/, unsigned int /*failed*/,
|
||||||
unsigned int /*totalCount*/)
|
unsigned int /*totalCount*/) { Logger::info() << "Processed files: " << pathsCount << Qt::endl; });
|
||||||
{
|
|
||||||
Logger::info() << "Processed files: " << pathsCount << Qt::endl;
|
|
||||||
if(verbose)
|
|
||||||
{
|
|
||||||
IndexResult indexResult = indexer->getResult();
|
|
||||||
int newlyAdded = indexResult.results.count() - currentResult.results.count();
|
|
||||||
int newOffset = 0;
|
|
||||||
if(newlyAdded > 0)
|
|
||||||
{
|
|
||||||
newOffset = indexResult.results.count() - newlyAdded;
|
|
||||||
for(int i = newOffset; i < indexResult.results.count(); i++)
|
|
||||||
{
|
|
||||||
auto result = indexResult.results.at(i);
|
|
||||||
Logger::info() << SaveFileResultToString(result.second) << result.first << Qt::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->currentResult = indexResult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
);
|
|
||||||
connect(indexer, &Indexer::finished, this, &CommandAdd::indexerFinished);
|
connect(indexer, &Indexer::finished, this, &CommandAdd::indexerFinished);
|
||||||
|
|
||||||
this->autoFinish = false;
|
this->autoFinish = false;
|
||||||
|
@ -13,8 +13,6 @@ class CommandAdd : public Command
|
|||||||
bool keepGoing = true;
|
bool keepGoing = true;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IndexResult currentResult;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Command::Command;
|
using Command::Command;
|
||||||
|
|
||||||
|
@ -111,20 +111,6 @@ void Indexer::dirScanProgress(int current, int total)
|
|||||||
|
|
||||||
void Indexer::processFileScanResult(FileScanResult result)
|
void Indexer::processFileScanResult(FileScanResult result)
|
||||||
{
|
{
|
||||||
/* TODO: OK_WASEMPTY might need a special list */
|
|
||||||
if(result.second == OK || result.second == OK_WASEMPTY)
|
|
||||||
{
|
|
||||||
++this->currentIndexResult.addedPaths;
|
|
||||||
}
|
|
||||||
else if(result.second == SKIPPED)
|
|
||||||
{
|
|
||||||
++this->currentIndexResult.skippedPaths;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
++this->currentIndexResult.erroredPaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isErrorSaveFileResult(result.second))
|
if(isErrorSaveFileResult(result.second))
|
||||||
{
|
{
|
||||||
this->currentIndexResult.results.append(result);
|
this->currentIndexResult.results.append(result);
|
||||||
@ -143,6 +129,20 @@ void Indexer::processFileScanResult(FileScanResult result)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: OK_WASEMPTY might need a special list */
|
||||||
|
if(result.second == OK || result.second == OK_WASEMPTY)
|
||||||
|
{
|
||||||
|
++this->currentIndexResult.addedPaths;
|
||||||
|
}
|
||||||
|
else if(result.second == SKIPPED)
|
||||||
|
{
|
||||||
|
++this->currentIndexResult.skippedPaths;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++this->currentIndexResult.erroredPaths;
|
||||||
|
}
|
||||||
|
|
||||||
QTime currentTime = QTime::currentTime();
|
QTime currentTime = QTime::currentTime();
|
||||||
if(currentScanProcessedCount++ == progressReportThreshold || this->lastProgressReportTime.secsTo(currentTime) >= 10)
|
if(currentScanProcessedCount++ == progressReportThreshold || this->lastProgressReportTime.secsTo(currentTime) >= 10)
|
||||||
{
|
{
|
||||||
@ -171,8 +171,3 @@ void Indexer::setFileSaverOptions(FileSaverOptions options)
|
|||||||
{
|
{
|
||||||
this->fileSaverOptions = options;
|
this->fileSaverOptions = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Indexer::setProgressReportThreshold(int threshold)
|
|
||||||
{
|
|
||||||
this->progressReportThreshold = threshold;
|
|
||||||
}
|
|
||||||
|
@ -82,8 +82,6 @@ class Indexer : public QObject
|
|||||||
|
|
||||||
void setFileSaverOptions(FileSaverOptions options);
|
void setFileSaverOptions(FileSaverOptions options);
|
||||||
|
|
||||||
void setProgressReportThreshold(int threshold);
|
|
||||||
|
|
||||||
void requestCancellation();
|
void requestCancellation();
|
||||||
|
|
||||||
Indexer(SqliteDbService &db);
|
Indexer(SqliteDbService &db);
|
||||||
|
Loading…
Reference in New Issue
Block a user