mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 07:05:57 -05:00
Make database location a configuration item
This commit is contained in:
parent
6c6a3a7935
commit
e6d75534d7
@ -3,6 +3,8 @@ general {
|
||||
# Username
|
||||
uid = "daapd"
|
||||
logfile = "/var/log/forked-daapd.log"
|
||||
# Database location
|
||||
# db_path = "/var/cache/forked-daapd/songs3.db"
|
||||
# Available levels: fatal, log, warning, info, debug, spam
|
||||
loglevel = log
|
||||
# Admin password for the non-existent web interface
|
||||
|
@ -43,6 +43,7 @@ static cfg_opt_t sec_general[] =
|
||||
CFG_STR("uid", "nobody", CFGF_NONE),
|
||||
CFG_STR("admin_password", NULL, CFGF_NONE),
|
||||
CFG_STR("logfile", STATEDIR "/log/" PACKAGE ".log", CFGF_NONE),
|
||||
CFG_STR("db_path", STATEDIR "/cache/" PACKAGE "/songs3.db", CFGF_NONE),
|
||||
CFG_INT_CB("loglevel", E_LOG, CFGF_NONE, &cb_loglevel),
|
||||
CFG_END()
|
||||
};
|
||||
|
7
src/db.c
7
src/db.c
@ -31,13 +31,13 @@
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
#include "conffile.h"
|
||||
#include "logger.h"
|
||||
#include "misc.h"
|
||||
#include "db.h"
|
||||
|
||||
|
||||
#define STR(x) ((x) ? (x) : "")
|
||||
#define DB_PATH STATEDIR "/cache/" PACKAGE "/songs3.db"
|
||||
|
||||
/* Inotify cookies are uint32_t */
|
||||
#define INOTIFY_FAKE_COOKIE ((int64_t)1 << 32)
|
||||
@ -232,6 +232,7 @@ static struct col_type_map wi_cols_map[] =
|
||||
{ wi_offsetof(path), DB_TYPE_STRING },
|
||||
};
|
||||
|
||||
static char *db_path;
|
||||
static __thread sqlite3 *hdl;
|
||||
|
||||
|
||||
@ -3345,7 +3346,7 @@ db_perthread_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = sqlite3_open(DB_PATH, &hdl);
|
||||
ret = sqlite3_open(db_path, &hdl);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Could not open database: %s\n", sqlite3_errmsg(hdl));
|
||||
@ -3928,6 +3929,8 @@ db_init(void)
|
||||
int pls;
|
||||
int ret;
|
||||
|
||||
db_path = cfg_getstr(cfg_getsec(cfg, "general"), "db_path");
|
||||
|
||||
if (!sqlite3_threadsafe())
|
||||
{
|
||||
DPRINTF(E_FATAL, L_DB, "The SQLite3 library is not built with a threadsafe configuration\n");
|
||||
|
Loading…
Reference in New Issue
Block a user