mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-23 12:43:18 -05:00
[db] Add cli parameter to overwrite path to SQLite extension
This will allow pointing to the locally build (and not installed) owntone SQLite extension during development and local testing.
This commit is contained in:
parent
ce3c617023
commit
9fbd07a75d
6
src/db.c
6
src/db.c
@ -652,6 +652,7 @@ db_pl_type_label(enum pl_type pl_type)
|
||||
struct rng_ctx shuffle_rng;
|
||||
|
||||
static char *db_path;
|
||||
static char *db_sqlite_ext_path;
|
||||
static bool db_rating_updates;
|
||||
|
||||
static __thread sqlite3 *hdl;
|
||||
@ -6957,7 +6958,7 @@ db_open(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = sqlite3_load_extension(hdl, PKGLIBDIR "/" PACKAGE_NAME "-sqlext.so", NULL, &errmsg);
|
||||
ret = sqlite3_load_extension(hdl, db_sqlite_ext_path, NULL, &errmsg);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Could not load SQLite extension: %s\n", errmsg);
|
||||
@ -7371,7 +7372,7 @@ db_check_version(void)
|
||||
}
|
||||
|
||||
int
|
||||
db_init(void)
|
||||
db_init(char *sqlite_ext_path)
|
||||
{
|
||||
uint32_t files;
|
||||
uint32_t pls;
|
||||
@ -7388,6 +7389,7 @@ db_init(void)
|
||||
}
|
||||
|
||||
db_path = cfg_getstr(cfg_getsec(cfg, "general"), "db_path");
|
||||
db_sqlite_ext_path = sqlite_ext_path;
|
||||
db_rating_updates = cfg_getbool(cfg_getsec(cfg, "library"), "rating_updates");
|
||||
|
||||
DPRINTF(E_INFO, L_DB, "Configured to use database file '%s'\n", db_path);
|
||||
|
2
src/db.h
2
src/db.h
@ -1029,7 +1029,7 @@ void
|
||||
db_perthread_deinit(void);
|
||||
|
||||
int
|
||||
db_init(void);
|
||||
db_init(char *sqlite_ext_path);
|
||||
|
||||
void
|
||||
db_deinit(void);
|
||||
|
16
src/main.c
16
src/main.c
@ -73,8 +73,9 @@
|
||||
# include "lastfm.h"
|
||||
#endif
|
||||
|
||||
#define PIDFILE STATEDIR "/run/" PACKAGE ".pid"
|
||||
#define WEB_ROOT DATADIR "/htdocs"
|
||||
#define PIDFILE STATEDIR "/run/" PACKAGE ".pid"
|
||||
#define WEB_ROOT DATADIR "/htdocs"
|
||||
#define SQLITE_EXT_PATH PKGLIBDIR "/" PACKAGE_NAME "-sqlext.so"
|
||||
|
||||
struct event_base *evbase_main;
|
||||
|
||||
@ -106,6 +107,7 @@ usage(char *program)
|
||||
printf(" --mdns-no-daap Don't announce DAAP service via mDNS\n");
|
||||
printf(" --mdns-no-cname Don't register owntone.local as CNAME via mDNS\n");
|
||||
printf(" --mdns-no-web Don't announce web interface via mDNS\n");
|
||||
printf(" -s <path> Use <path> as the path for the OwnTone sqlite extension (owntone-sqlext.so)\n");
|
||||
printf("\n\n");
|
||||
printf("Available log domains:\n");
|
||||
logger_domains();
|
||||
@ -495,6 +497,7 @@ main(int argc, char **argv)
|
||||
char *ffid = NULL;
|
||||
char *pidfile = PIDFILE;
|
||||
char *webroot = WEB_ROOT;
|
||||
char *sqlite_extension_path = SQLITE_EXT_PATH;
|
||||
char **buildopts;
|
||||
const char *av_version;
|
||||
const char *gcry_version;
|
||||
@ -516,6 +519,7 @@ main(int argc, char **argv)
|
||||
{ "pidfile", 1, NULL, 'P' },
|
||||
{ "version", 0, NULL, 'v' },
|
||||
{ "webroot", 1, NULL, 'w' },
|
||||
{ "sqliteext", 1, NULL, 's' },
|
||||
{ "testrun", 0, NULL, 't' }, // Used for CI, not documented to user
|
||||
|
||||
{ "mdns-no-rsp", 0, NULL, 512 },
|
||||
@ -526,7 +530,7 @@ main(int argc, char **argv)
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
while ((option = getopt_long(argc, argv, "D:d:c:P:ftb:vw:", option_map, NULL)) != -1)
|
||||
while ((option = getopt_long(argc, argv, "D:d:c:P:ftb:vw:s:", option_map, NULL)) != -1)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
@ -587,6 +591,10 @@ main(int argc, char **argv)
|
||||
webroot = optarg;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
sqlite_extension_path = optarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
@ -739,7 +747,7 @@ main(int argc, char **argv)
|
||||
|
||||
/* Initialize the database before starting */
|
||||
DPRINTF(E_INFO, L_MAIN, "Initializing database\n");
|
||||
ret = db_init();
|
||||
ret = db_init(sqlite_extension_path);
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_FATAL, L_MAIN, "Database init failed\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user