mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-23 12:43:18 -05:00
Introduce db_file_id_byfilebase and db_file_id_byfile
File id lookup by basepath + filename and filename only.
This commit is contained in:
parent
66cd10dc52
commit
a6cbb2a8ec
48
src/db.c
48
src/db.c
@ -997,6 +997,54 @@ db_file_id_bypath(char *path)
|
||||
#undef Q_TMPL
|
||||
}
|
||||
|
||||
int
|
||||
db_file_id_byfilebase(char *filename, char *base)
|
||||
{
|
||||
#define Q_TMPL "SELECT id FROM files WHERE path LIKE '%q/%%/%q';"
|
||||
char *query;
|
||||
int ret;
|
||||
|
||||
query = sqlite3_mprintf(Q_TMPL, base, filename);
|
||||
if (!query)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = db_file_id_byquery(query);
|
||||
|
||||
sqlite3_free(query);
|
||||
|
||||
return ret;
|
||||
|
||||
#undef Q_TMPL
|
||||
}
|
||||
|
||||
int
|
||||
db_file_id_byfile(char *filename)
|
||||
{
|
||||
#define Q_TMPL "SELECT id FROM files WHERE fname = '%q';"
|
||||
char *query;
|
||||
int ret;
|
||||
|
||||
query = sqlite3_mprintf(Q_TMPL, filename);
|
||||
if (!query)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = db_file_id_byquery(query);
|
||||
|
||||
sqlite3_free(query);
|
||||
|
||||
return ret;
|
||||
|
||||
#undef Q_TMPL
|
||||
}
|
||||
|
||||
int
|
||||
db_file_id_byurl(char *url)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user