[db] add db_watch_enum_fetch() to return all watch_info

This commit is contained in:
whatdoineed2do/Ray 2021-01-29 22:07:42 +00:00
parent f76003ca9e
commit de3268eddf
2 changed files with 40 additions and 3 deletions

View File

@ -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

View File

@ -1026,7 +1026,10 @@ int
db_watch_enum_fetchwd(struct watch_enum *we, uint32_t *wd);
int
db_backup(void);
db_watch_enum_fetch(struct watch_enum *we, struct watch_info *wi);
int
db_backup();
int
db_perthread_init(void);