Commit 4ff17581 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Task: Fix in-progress tasks resuming

We were trying to re-create a file during each resume, which could only
work if the task got interrupted during the extraction step
parent ee42154a
......@@ -118,6 +118,7 @@ parser::Task::Status MetadataParser::run( parser::Task& task )
LOG_ERROR( "Failed to add file ", task.mrl, " to media #", task.media->id() );
return parser::Task::Status::Fatal;
}
task.updateFileId();
t->commit();
}
// Voluntarily trigger an exception for a valid, but less common case, to avoid database overhead
......
......@@ -73,6 +73,7 @@ Task::Task( MediaLibraryPtr ml, std::shared_ptr<fs::IFile> fileFs,
, currentService( 0 )
, m_ml( ml )
, m_step( ParserStep::None )
, m_fileId( 0 )
{
}
......@@ -114,6 +115,18 @@ void Task::startParserStep()
sqlite::Tools::executeUpdate( m_ml->getConn(), req, m_id );
}
bool Task::updateFileId()
{
assert( m_fileId == 0 );
assert( file != nullptr && file->id() != 0 );
static const std::string req = "UPDATE " + policy::TaskTable::Name + " SET "
"file_id = ? WHERE id_task = ?";
if ( sqlite::Tools::executeUpdate( m_ml->getConn(), req, file->id(), m_id ) == false )
return false;
m_fileId = file->id();
return true;
}
bool Task::restoreLinkedEntities( )
{
auto fsFactory = m_ml->fsFactoryForMrl( mrl );
......
......@@ -119,6 +119,8 @@ public:
*/
void startParserStep();
bool updateFileId();
// Restore attached entities such as media/files
bool restoreLinkedEntities();
......
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