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

MediaLibrary: Bump db model to 12

This version will ensure all the File have an associated Task, to avoid
some content not appearing because it wasn't analyzed
parent 64a241e7
......@@ -831,6 +831,11 @@ InitializeResult MediaLibrary::updateDatabaseModel( unsigned int previousVersion
migrateModel10to11();
previousVersion = 11;
}
if ( previousVersion == 11 )
{
parser::Task::recoverUnscannedFiles( this );
previousVersion = 12;
}
// To be continued in the future!
if ( needRescan == true )
......
......@@ -32,7 +32,7 @@
namespace medialibrary
{
const uint32_t Settings::DbModelVersion = 11u;
const uint32_t Settings::DbModelVersion = 12u;
Settings::Settings( MediaLibrary* ml )
: m_ml( ml )
......
......@@ -301,6 +301,16 @@ Task::create( MediaLibraryPtr ml, std::shared_ptr<fs::IFile> fileFs,
return self;
}
void Task::recoverUnscannedFiles( MediaLibraryPtr ml )
{
static const std::string req = "INSERT INTO " + policy::TaskTable::Name +
"(file_id, parent_folder_id)"
" SELECT id_file, folder_id FROM " + policy::FileTable::Name +
" f LEFT JOIN " + policy::TaskTable::Name + " t"
" ON t.file_id = f.id_file WHERE t.file_id IS NULL";
sqlite::Tools::executeInsert( ml->getConn(), req );
}
}
}
......@@ -145,6 +145,7 @@ public:
std::shared_ptr<Folder> parentFolder,
std::shared_ptr<fs::IDirectory> parentFolderFs,
std::pair<std::shared_ptr<Playlist>, unsigned int> parentPlaylist );
static void recoverUnscannedFiles( MediaLibraryPtr ml );
private:
MediaLibraryPtr m_ml;
......
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