Commit 71e5bcf1 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

parser: Fix infinite metadata analysis retries

parent 4b32c226
......@@ -222,7 +222,19 @@ 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 task.resetRetryCountOnSuccess();
// We don't want to reset the entire retry count, as we would be stuck in
// a "loop" in case the metadata analysis fails (we'd always reset the retry
// count to zero, then fail, then run the extraction again, reset the retry,
// fail the analysis, and so on.
// We can't not increment the retry count for metadata extraction, since
// in case a file makes (lib)VLC crash, we would always try again, and
// therefor we would keep on crashing.
// However we don't want to just increment the retry count, since it
// would reach the maximum value too quickly (extraction would set retry
// count to 1, analysis to 2, and in case of failure, next run would set
// it over 3, while we only tried 2 times. Instead we just decrement it
// when the extraction step succeeds
return task.decrementRetryCount();
else if ( status == Status::Completed )
......@@ -93,10 +93,10 @@ bool Task::saveParserStep()
return sqlite::Tools::executeUpdate( m_ml->getConn(), req, m_step, m_id );
bool Task::resetRetryCountOnSuccess()
bool Task::decrementRetryCount()
static const std::string req = "UPDATE " + Task::Table::Name + " SET "
"retry_count = 0 WHERE id_task = ?";
"retry_count = retry_count - 1 WHERE id_task = ?";
return sqlite::Tools::executeUpdate( m_ml->getConn(), req, m_id );
......@@ -173,7 +173,7 @@ public:
// 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 decrementRetryCount();
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