From 944bf3f13285450c218a6186be042d5a7aab11d7 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Thu, 21 Jan 2010 17:51:00 +0100 Subject: [PATCH] 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. --- src/db.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/db.c b/src/db.c index 00b868bc..7982e370 100644 --- a/src/db.c +++ b/src/db.c @@ -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();