Commit 7aac3823 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Parser: Move fetching of unparsed files in the File class

parent 8fec9b76
......@@ -275,6 +275,13 @@ std::shared_ptr<File> File::fromExternalMrl( MediaLibraryPtr ml, const std::stri
return file;
}
std::vector<std::shared_ptr<File>> File::fetchUnparsed( MediaLibraryPtr ml )
{
static const std::string req = "SELECT * FROM " + policy::FileTable::Name
+ " WHERE parser_step != ? AND is_present = 1 AND folder_id IS NOT NULL AND parser_retries < 3";
return File::fetchAll<File>( ml, req, File::ParserStep::Completed );
}
void File::resetRetryCount( MediaLibraryPtr ml )
{
static const std::string req = "UPDATE " + policy::FileTable::Name + " SET "
......
......@@ -113,6 +113,7 @@ public:
*/
static std::shared_ptr<File> fromExternalMrl( MediaLibraryPtr ml, const std::string& mrl );
static std::vector<std::shared_ptr<File>> fetchUnparsed( MediaLibraryPtr ml );
static void resetRetryCount( MediaLibraryPtr ml );
private:
......
......@@ -101,10 +101,7 @@ void Parser::restore()
if ( m_services.empty() == true )
return;
static const std::string req = "SELECT * FROM " + policy::FileTable::Name
+ " WHERE parser_step != ? AND is_present = 1 AND folder_id IS NOT NULL AND parser_retries < 3";
auto files = File::fetchAll<File>( m_ml, req, File::ParserStep::Completed );
auto files = File::fetchUnparsed( m_ml );
LOG_INFO( "Resuming parsing on ", files.size(), " mrl" );
for ( auto& f : files )
{
......
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