Commit 8fec9b76 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

MediaLibrary: Allow unfinished parsing to be forcefully restarted

parent 361fc574
......@@ -255,6 +255,11 @@ class IMediaLibrary
virtual void resumeBackgroundOperations() = 0;
virtual void reload() = 0;
virtual void reload( const std::string& entryPoint ) = 0;
/**
* @brief forceParserRetry Forces a re-run of all metadata parsers and resets any
* unterminated file retry count to 0, granting them 3 new tries at being parsed
*/
virtual void forceParserRetry() = 0;
/**
* @brief setDeviceLister Sets a device lister.
......
......@@ -275,4 +275,11 @@ std::shared_ptr<File> File::fromExternalMrl( MediaLibraryPtr ml, const std::stri
return file;
}
void File::resetRetryCount( MediaLibraryPtr ml )
{
static const std::string req = "UPDATE " + policy::FileTable::Name + " SET "
"parser_retries = 0 WHERE parser_step != ? AND is_present = 1 AND folder_id IS NOT NULL";
sqlite::Tools::executeUpdate( ml->getConn(), req, ParserStep::Completed );
}
}
......@@ -113,6 +113,7 @@ public:
*/
static std::shared_ptr<File> fromExternalMrl( MediaLibraryPtr ml, const std::string& mrl );
static void resetRetryCount( MediaLibraryPtr ml );
private:
MediaLibraryPtr m_ml;
......
......@@ -653,6 +653,11 @@ void MediaLibrary::reload( const std::string& entryPoint )
m_discoverer->reload( entryPoint );
}
void MediaLibrary::forceParserRetry()
{
File::resetRetryCount( this );
}
void MediaLibrary::pauseBackgroundOperations()
{
if ( m_parser != nullptr )
......
......@@ -125,6 +125,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
//Temporarily public, move back to private as soon as we start monitoring the FS
virtual void reload() override;
virtual void reload( const std::string& entryPoint ) override;
virtual void forceParserRetry() override;
virtual void pauseBackgroundOperations() override;
virtual void resumeBackgroundOperations() override;
......
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