From b5bf1928ffd5fd4458f310e4c8509dc700d4c4c1 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 3 Dec 2016 07:00:28 +0100 Subject: [PATCH] [db] Rename "plversion" to "queue_version", add missing init query for queue_version --- src/db.c | 28 ++++++++++++++-------------- src/db_init.c | 4 ++++ src/db_upgrade.c | 6 +++--- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/db.c b/src/db.c index b37664de..75862bcc 100644 --- a/src/db.c +++ b/src/db.c @@ -4204,14 +4204,14 @@ int db_queue_get_version() { char *version; - int32_t plversion; + int32_t queue_version; int ret; - plversion = 0; - version = db_admin_get("plversion"); + queue_version = 0; + version = db_admin_get("queue_version"); if (version) { - ret = safe_atoi32(version, &plversion); + ret = safe_atoi32(version, &queue_version); free(version); if (ret < 0) { @@ -4220,7 +4220,7 @@ db_queue_get_version() } } - return plversion; + return queue_version; } /* @@ -4233,29 +4233,29 @@ db_queue_get_version() static void queue_inc_version_and_notify() { - int plversion; + int queue_version; char version[10]; int ret; db_transaction_begin(); - plversion = db_queue_get_version(); - if (plversion < 0) - plversion = 0; + queue_version = db_queue_get_version(); + if (queue_version < 0) + queue_version = 0; - plversion++; - ret = snprintf(version, sizeof(version), "%d", plversion); + queue_version++; + ret = snprintf(version, sizeof(version), "%d", queue_version); if (ret >= sizeof(version)) { - DPRINTF(E_LOG, L_DB, "Error incrementing queue version. Could not convert version to string: %d\n", plversion); + DPRINTF(E_LOG, L_DB, "Error incrementing queue version. Could not convert version to string: %d\n", queue_version); db_transaction_rollback(); return; } - ret = db_admin_update("plversion", version); + ret = db_admin_update("queue_version", version); if (ret < 0) { - DPRINTF(E_LOG, L_DB, "Error incrementing queue version. Could not update version in admin table: %d\n", plversion); + DPRINTF(E_LOG, L_DB, "Error incrementing queue version. Could not update version in admin table: %d\n", queue_version); db_transaction_rollback(); return; } diff --git a/src/db_init.c b/src/db_init.c index 1d510942..b92dd822 100644 --- a/src/db_init.c +++ b/src/db_init.c @@ -242,6 +242,9 @@ "INSERT INTO directories (id, virtual_path, db_timestamp, disabled, parent_id)" \ " VALUES (4, '/spotify:', 0, 4294967296, 1);" +#define Q_QUEUE_VERSION \ + "INSERT INTO admin (key, value) VALUES ('queue_version', '0');" + #define Q_SCVER_MAJOR \ "INSERT INTO admin (key, value) VALUES ('schema_version_major', '%d');" #define Q_SCVER_MINOR \ @@ -278,6 +281,7 @@ static const struct db_init_query db_init_table_queries[] = { Q_DIR2, "create default base directory '/file:'" }, { Q_DIR3, "create default base directory '/http:'" }, { Q_DIR4, "create default base directory '/spotify:'" }, + { Q_QUEUE_VERSION, "initialize queue version" }, }; diff --git a/src/db_upgrade.c b/src/db_upgrade.c index 56e4315f..799a7dc6 100644 --- a/src/db_upgrade.c +++ b/src/db_upgrade.c @@ -1471,8 +1471,8 @@ db_upgrade_v19(sqlite3 *hdl) " disc INTEGER DEFAULT 0" \ ");" -#define U_V2000_PLVERSION \ - "INSERT INTO admin (key, value) VALUES ('plversion', '0');" +#define U_V2000_QUEUE_VERSION \ + "INSERT INTO admin (key, value) VALUES ('queue_version', '0');" #define U_V2000_SCVER_MAJOR \ "UPDATE admin SET value = '20' WHERE key = 'schema_version_major';" @@ -1482,7 +1482,7 @@ db_upgrade_v19(sqlite3 *hdl) static const struct db_upgrade_query db_upgrade_v2000_queries[] = { { U_V2000_CREATE_TABLE_QUEUE, "create table directories" }, - { U_V2000_PLVERSION, "insert plversion" }, + { U_V2000_QUEUE_VERSION, "insert plversion" }, { U_V2000_SCVER_MAJOR, "set schema_version_major to 20" }, { U_V2000_SCVER_MINOR, "set schema_version_minor to 00" },