Commit 1856e8bf authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

parser: Handle completed & discarded tasks from the worker

parent cbfb9657
......@@ -100,9 +100,7 @@ parser::Task::Status MetadataParser::run( parser::Task& task )
return parser::Task::Status::Fatal;
assert( task.item().file() != nullptr );
task.markStepCompleted( parser::Task::ParserStep::Completed );
task.saveParserStep();
return parser::Task::Status::Success;
return parser::Task::Status::Completed;
}
if ( task.item().file() == nullptr )
......@@ -171,13 +169,7 @@ parser::Task::Status MetadataParser::run( parser::Task& task )
task.item().parentPlaylist()->add( task.item().media()->id(), task.item().parentPlaylistIndex() );
if ( alreadyInParser == true )
{
// Let the worker drop this duplicate task
task.markStepCompleted( parser::Task::ParserStep::Completed );
// And remove it from DB
parser::Task::destroy( m_ml, task.id() );
return parser::Task::Status::Success;
}
return parser::Task::Status::Discarded;
const auto& tracks = task.item().tracks();
......
......@@ -150,8 +150,19 @@ void Parser::done( std::shared_ptr<parser::Task> t, parser::Task::Status status
auto serviceIdx = ++t->currentService;
if ( status == parser::Task::Status::Completed )
{
t->markStepCompleted( parser::Task::ParserStep::Completed );
t->saveParserStep();
}
else if ( status == parser::Task::Status::Discarded )
{
parser::Task::destroy( m_ml, t->id() );
}
if ( status == parser::Task::Status::TemporaryUnavailable ||
status == parser::Task::Status::Fatal || t->isCompleted() )
status == parser::Task::Status::Fatal ||
status == parser::Task::Status::Discarded ||
t->isCompleted() )
{
if ( serviceIdx < m_services.size() )
{
......
......@@ -84,7 +84,14 @@ public:
/// isn't connected anymore)
TemporaryUnavailable,
/// Something failed and we won't continue
Fatal
Fatal,
/// The task must now be considered completed, regardless of the
/// current step.
Completed,
/// The task should be discarded, regardless of its status
/// This is likely to be used when trying to parse playlist items,
/// as they already could have been queued before.
Discarded,
};
enum class ParserStep : uint8_t
......
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