cli: CommandAdd: Set keepGoing, Remove verbose for now

This commit is contained in:
Albert S. 2022-06-06 09:33:56 +02:00
parent f8542dc96a
commit 744fa2ec7a
2 changed files with 9 additions and 8 deletions

View File

@ -29,8 +29,12 @@ void CommandAdd::indexerFinished()
} }
} }
/* TODO maybe not 0 if keepGoing not given */ int ret = 0;
emit finishedCmd(0); if(!keepGoing && failedPathsCount > 0)
{
ret = 1;
}
emit finishedCmd(ret);
} }
int CommandAdd::handle(QStringList arguments) int CommandAdd::handle(QStringList arguments)
@ -40,15 +44,13 @@ int CommandAdd::handle(QStringList arguments)
"Continue adding files, don't exit on first error. If this option is not given, looqs will " "Continue adding files, don't exit on first error. If this option is not given, looqs will "
"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. "},
{{"v", "verbose"}, "Print skipped and added files"},
{{"t", "threads"}, "Number of threads to use.", "threads"}}); {{"t", "threads"}, "Number of threads to use.", "threads"}});
parser.addHelpOption(); parser.addHelpOption();
parser.addPositionalArgument("add", "Add paths to the index", "add [paths...]"); parser.addPositionalArgument("add", "Add paths to the index", "add [paths...]");
parser.process(arguments); parser.process(arguments);
bool keepGoing = parser.isSet("continue"); this->keepGoing = parser.isSet("continue");
bool verbose = parser.isSet("verbose");
if(parser.isSet("threads")) if(parser.isSet("threads"))
{ {
QString threadsCount = parser.value("threads"); QString threadsCount = parser.value("threads");
@ -70,17 +72,15 @@ int CommandAdd::handle(QStringList arguments)
indexer = new Indexer(*this->dbService); indexer = new Indexer(*this->dbService);
indexer->setTargetPaths(files.toVector()); indexer->setTargetPaths(files.toVector());
indexer->setKeepGoing(keepGoing);
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,
[](int pathsCount, unsigned int added, unsigned int skipped, unsigned int failed, unsigned int totalCount) [](int pathsCount, unsigned int added, unsigned int skipped, unsigned int failed, unsigned int totalCount)
{ Logger::info() << "Processed files: " << pathsCount << Qt::endl; }); { Logger::info() << "Processed files: " << pathsCount << Qt::endl; });
connect(indexer, &Indexer::finished, this, &CommandAdd::indexerFinished); connect(indexer, &Indexer::finished, this, &CommandAdd::indexerFinished);
/* TODO: keepGoing, verbose */
this->autoFinish = false; this->autoFinish = false;
indexer->beginIndexing(); indexer->beginIndexing();

View File

@ -10,6 +10,7 @@ class CommandAdd : public Command
private: private:
SaveFileResult addFile(QString path); SaveFileResult addFile(QString path);
Indexer *indexer; Indexer *indexer;
bool keepGoing = true;
protected: protected:
public: public: