mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-27 04:46:56 -05:00
[db] add db_watch_enum_fetch() to return all watch_info
This commit is contained in:
38
src/db.c
38
src/db.c
@@ -6530,8 +6530,8 @@ db_watch_cookie_known(uint32_t cookie)
|
|||||||
int
|
int
|
||||||
db_watch_enum_start(struct watch_enum *we)
|
db_watch_enum_start(struct watch_enum *we)
|
||||||
{
|
{
|
||||||
#define Q_MATCH_TMPL "SELECT wd FROM inotify WHERE path LIKE '%q/%%';"
|
#define Q_MATCH_TMPL "SELECT wd,path FROM inotify WHERE path LIKE '%q/%%';"
|
||||||
#define Q_COOKIE_TMPL "SELECT wd FROM inotify WHERE cookie = %" PRIi64 ";"
|
#define Q_COOKIE_TMPL "SELECT wd,path FROM inotify WHERE cookie = %" PRIi64 ";"
|
||||||
sqlite3_stmt *stmt;
|
sqlite3_stmt *stmt;
|
||||||
char *query;
|
char *query;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -6616,6 +6616,40 @@ db_watch_enum_fetchwd(struct watch_enum *we, uint32_t *wd)
|
|||||||
return 0;
|
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
|
#ifdef DB_PROFILE
|
||||||
static int
|
static int
|
||||||
|
|||||||
5
src/db.h
5
src/db.h
@@ -1026,7 +1026,10 @@ int
|
|||||||
db_watch_enum_fetchwd(struct watch_enum *we, uint32_t *wd);
|
db_watch_enum_fetchwd(struct watch_enum *we, uint32_t *wd);
|
||||||
|
|
||||||
int
|
int
|
||||||
db_backup(void);
|
db_watch_enum_fetch(struct watch_enum *we, struct watch_info *wi);
|
||||||
|
|
||||||
|
int
|
||||||
|
db_backup();
|
||||||
|
|
||||||
int
|
int
|
||||||
db_perthread_init(void);
|
db_perthread_init(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user