mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-28 16:15:57 -05:00
Check database version first, if that fails, try DB init
Doing it the other way around is a guaranteed way to run into issues when a schema upgrade is needed.
This commit is contained in:
parent
87abc3f432
commit
944bf3f132
20
src/db.c
20
src/db.c
@ -3140,20 +3140,18 @@ db_init(void)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = db_create_tables();
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
DPRINTF(E_FATAL, L_DB, "Could not create tables\n");
|
|
||||||
db_perthread_deinit();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = db_check_version();
|
ret = db_check_version();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_FATAL, L_DB, "Could not check database version\n");
|
DPRINTF(E_FATAL, L_DB, "Could not check database version, trying DB init\n");
|
||||||
db_perthread_deinit();
|
|
||||||
return -1;
|
ret = db_create_tables();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
DPRINTF(E_FATAL, L_DB, "Could not create tables\n");
|
||||||
|
db_perthread_deinit();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
files = db_files_get_count();
|
files = db_files_get_count();
|
||||||
|
Loading…
Reference in New Issue
Block a user