mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-15 08:45:54 -04:00
Add DB maintenance routines
This commit is contained in:
parent
0b2df54524
commit
3caae459be
29
src/db.c
29
src/db.c
@ -568,6 +568,35 @@ db_exec(const char *query, char **errmsg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Maintenance and DB hygiene */
|
||||||
|
static void
|
||||||
|
db_analyze(void)
|
||||||
|
{
|
||||||
|
char *query = "ANALYZE;";
|
||||||
|
char *errmsg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query);
|
||||||
|
|
||||||
|
ret = db_exec(query, &errmsg);
|
||||||
|
if (ret != SQLITE_OK)
|
||||||
|
{
|
||||||
|
DPRINTF(E_LOG, L_DB, "ANALYZE failed: %s\n", errmsg);
|
||||||
|
|
||||||
|
sqlite3_free(errmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
db_hook_post_scan(void)
|
||||||
|
{
|
||||||
|
DPRINTF(E_DBG, L_DB, "Running post-scan DB maintenance tasks...\n");
|
||||||
|
|
||||||
|
db_analyze();
|
||||||
|
|
||||||
|
DPRINTF(E_DBG, L_DB, "Done with post-scan DB maintenance\n");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
db_purge_cruft(time_t ref)
|
db_purge_cruft(time_t ref)
|
||||||
{
|
{
|
||||||
|
4
src/db.h
4
src/db.h
@ -286,6 +286,10 @@ unicode_fixup_mfi(struct media_file_info *mfi);
|
|||||||
void
|
void
|
||||||
free_pli(struct playlist_info *pli, int content_only);
|
free_pli(struct playlist_info *pli, int content_only);
|
||||||
|
|
||||||
|
/* Maintenance and DB hygiene */
|
||||||
|
void
|
||||||
|
db_hook_post_scan(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
db_purge_cruft(time_t ref);
|
db_purge_cruft(time_t ref);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user