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

MediaLibrary: Split database re-creation in a separate function

parent d19b410c
......@@ -736,13 +736,7 @@ bool MediaLibrary::updateDatabaseModel( unsigned int previousVersion )
// It's also way simpler to implement
if ( previousVersion < 3 )
{
// Way too much differences, introduction of devices, and almost unused in the wild, just drop everything
std::string req = "PRAGMA writable_schema = 1;"
"delete from sqlite_master;"
"PRAGMA writable_schema = 0;";
if ( sqlite::Tools::executeRequest( getConn(), req ) == false )
return false;
if ( createAllTables() == false )
if( recreateDatabase() == false )
return false;
previousVersion = 3;
}
......@@ -761,6 +755,19 @@ bool MediaLibrary::updateDatabaseModel( unsigned int previousVersion )
return true;
}
bool MediaLibrary::recreateDatabase()
{
// Way too much differences, introduction of devices, and almost unused in the wild, just drop everything
std::string req = "PRAGMA writable_schema = 1;"
"delete from sqlite_master;"
"PRAGMA writable_schema = 0;";
if ( sqlite::Tools::executeRequest( getConn(), req ) == false )
return false;
if ( createAllTables() == false )
return false;
return true;
}
bool MediaLibrary::migrateModel3to4()
{
/*
......
......@@ -158,6 +158,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
virtual void startParser();
virtual void startDiscoverer();
virtual void startDeletionNotifier();
bool recreateDatabase();
bool updateDatabaseModel( unsigned int previousVersion );
bool migrateModel3to4();
bool createAllTables();
......
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