Add DB maintenance routines

This commit is contained in:
Peter Carmichael 2010-12-05 12:22:52 +01:00 committed by Julien BLACHE
parent 0b2df54524
commit 3caae459be
2 changed files with 33 additions and 0 deletions

View File

@ -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
db_purge_cruft(time_t ref)
{

View File

@ -286,6 +286,10 @@ unicode_fixup_mfi(struct media_file_info *mfi);
void
free_pli(struct playlist_info *pli, int content_only);
/* Maintenance and DB hygiene */
void
db_hook_post_scan(void);
void
db_purge_cruft(time_t ref);