[db] Rename "plversion" to "queue_version", add missing init query for

queue_version
This commit is contained in:
chme 2016-12-03 07:00:28 +01:00
parent 6c7df96371
commit b5bf1928ff
3 changed files with 21 additions and 17 deletions

View File

@ -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;
}

View File

@ -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" },
};

View File

@ -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" },