Commit 57ed3b93 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Task: Don't increment retry count twice for each analysis

parent 27122a2f
......@@ -222,7 +222,7 @@ bool Worker::handleServiceResult( Task& task, Status status )
// the extraction again, causing the analysis to run with no info.
if ( m_service->targetedStep() != Step::MetadataExtraction )
return task.saveParserStep();
return true;
return task.resetRetryCountOnSuccess();
}
else if ( status == Status::Completed )
{
......
......@@ -95,6 +95,13 @@ bool Task::saveParserStep()
return true;
}
bool Task::resetRetryCountOnSuccess()
{
static const std::string req = "UPDATE " + policy::TaskTable::Name + " SET "
"retry_count = 0 WHERE id_task = ?";
return sqlite::Tools::executeUpdate( m_ml->getConn(), req, m_id );
}
bool Task::isCompleted() const
{
using StepType = typename std::underlying_type<Step>::type;
......
......@@ -173,6 +173,11 @@ public:
*/
void markStepCompleted( parser::Step stepCompleted );
bool saveParserStep();
// Reset the retry count to 0 but doesn't advance the step.
// This is intended to be used when a step requires its completion not to be
// saved in database, but to avoid having a retry_count being incremented again
// when starting next step.
bool resetRetryCountOnSuccess();
bool isCompleted() const;
bool isStepCompleted( parser::Step step ) const;
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment