Commit 361fc574 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Parser: Fix potential infinite retry

parent 3f7473b4
......@@ -133,6 +133,12 @@ void File::markStepCompleted( ParserStep step )
static_cast<uint8_t>( step ) );
}
void File::markStepUncompleted(File::ParserStep step)
{
m_parserSteps = static_cast<ParserStep>( static_cast<uint8_t>( m_parserSteps ) &
( ~ static_cast<uint8_t>( step ) ) );
}
bool File::saveParserStep()
{
static const std::string req = "UPDATE " + policy::FileTable::Name + " SET parser_step = ?, "
......
......@@ -75,6 +75,7 @@ public:
* extract the same information again
*/
void markStepCompleted( ParserStep step );
void markStepUncompleted( ParserStep step );
bool saveParserStep();
ParserStep parserStep() const;
/**
......
......@@ -77,6 +77,11 @@ parser::Task::Status MetadataParser::run( parser::Task& task )
// However, if the file is not unknown anymore, it means the thumbnailer has already processed it
if ( task.media->type() == Media::Type::Unknown )
{
// In case the thumbnailer ran before, but the application exited, we would skip the
// thumbnailer execution, coming back here, and delegating again to the thumbnailer
// over and over again. We need to ensure the thumbnailer will run, even partially, up to
// the point the playback started.
task.file->markStepUncompleted( File::ParserStep::Thumbnailer );
LOG_INFO( "Skipping metadata parsing for file with unknown type: ", task.file->mrl() );
return parser::Task::Status::Success;
}
......
......@@ -122,6 +122,18 @@ parser::Task::Status VLCThumbnailer::run( parser::Task& task )
LOG_WARN( "Failed to generate ", file->mrl(), " thumbnail: Can't start playback" );
return res;
}
// Yet another special case:
// We could have run the thumbnailer already as a fallback for some weird video with no
// preparse detected tracks. If so, we don't want to spend more time computing a thumbnail, but
// we do need to run the metadata extraction again.
if ( media->type() == Media::Type::Unknown && media->thumbnail().empty() == false )
{
file->markStepCompleted( File::ParserStep::Thumbnailer );
// startPlayback will return an error in case the media is an audio file
media->setType( IMedia::Type::Video );
// And now let the metadata extraction run again
return parser::Task::Status::Success;
}
if ( duration <= 0 )
{
......
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