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:
Julien BLACHE 2010-01-21 17:51:00 +01:00
parent 87abc3f432
commit 944bf3f132

View File

@ -3140,20 +3140,18 @@ db_init(void)
if (ret < 0)
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();
if (ret < 0)
{
DPRINTF(E_FATAL, L_DB, "Could not check database version\n");
db_perthread_deinit();
return -1;
DPRINTF(E_FATAL, L_DB, "Could not check database version, trying DB init\n");
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();