mirror of
https://github.com/owntone/owntone-server.git
synced 2025-07-21 06:21:19 -04:00
[db] add db_watch_enum_fetch() to return all watch_info
This commit is contained in:
parent
f76003ca9e
commit
de3268eddf
38
src/db.c
38
src/db.c
@ -6530,8 +6530,8 @@ db_watch_cookie_known(uint32_t cookie)
|
||||
int
|
||||
db_watch_enum_start(struct watch_enum *we)
|
||||
{
|
||||
#define Q_MATCH_TMPL "SELECT wd FROM inotify WHERE path LIKE '%q/%%';"
|
||||
#define Q_COOKIE_TMPL "SELECT wd FROM inotify WHERE cookie = %" PRIi64 ";"
|
||||
#define Q_MATCH_TMPL "SELECT wd,path FROM inotify WHERE path LIKE '%q/%%';"
|
||||
#define Q_COOKIE_TMPL "SELECT wd,path FROM inotify WHERE cookie = %" PRIi64 ";"
|
||||
sqlite3_stmt *stmt;
|
||||
char *query;
|
||||
int ret;
|
||||
@ -6616,6 +6616,40 @@ db_watch_enum_fetchwd(struct watch_enum *we, uint32_t *wd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
db_watch_enum_fetch(struct watch_enum *we, struct watch_info *wi)
|
||||
{
|
||||
int ret;
|
||||
|
||||
wi->wd = 0;
|
||||
wi->cookie = 0;
|
||||
|
||||
if (!we->stmt)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Watch enum not started!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = db_blocking_step(we->stmt);
|
||||
if (ret == SQLITE_DONE)
|
||||
{
|
||||
DPRINTF(E_INFO, L_DB, "End of watch enum results\n");
|
||||
return 0;
|
||||
}
|
||||
else if (ret != SQLITE_ROW)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(hdl));
|
||||
return -1;
|
||||
}
|
||||
|
||||
wi->wd = (uint32_t)sqlite3_column_int(we->stmt, 0);
|
||||
if (wi->path)
|
||||
snprintf(wi->path, PATH_MAX, (char*)sqlite3_column_text(we->stmt, 1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef DB_PROFILE
|
||||
static int
|
||||
|
Loading…
x
Reference in New Issue
Block a user