diff --git a/src/lib/cache_disk.c b/src/lib/cache_disk.c index 56767e913..d41fae255 100644 --- a/src/lib/cache_disk.c +++ b/src/lib/cache_disk.c @@ -24,35 +24,31 @@ static int crop_dir(sds cache_basedir, const char *type, int keepdays); // public functions /** - * Clears the caches - * @param cachedir covercache directory - * @param keepdays delete files older than this number of days - * @return deleted file count on success, else -1 + * Clears the caches unconditionally + * @param config pointer to static config */ void cache_disk_clear(struct t_config *config) { - if (config->cache_cover_keep_days > CACHE_DISK_DISABLED) { - crop_dir(config->cachedir, DIR_CACHE_COVER, config->cache_cover_keep_days); - } - if (config->cache_lyrics_keep_days > CACHE_DISK_DISABLED) { - crop_dir(config->cachedir, DIR_CACHE_LYRICS, config->cache_lyrics_keep_days); - } - if (config->cache_thumbs_keep_days > CACHE_DISK_DISABLED) { - crop_dir(config->cachedir, DIR_CACHE_THUMBS, config->cache_thumbs_keep_days); - } + crop_dir(config->cachedir, DIR_CACHE_COVER, config->cache_cover_keep_days); + crop_dir(config->cachedir, DIR_CACHE_LYRICS, config->cache_lyrics_keep_days); + crop_dir(config->cachedir, DIR_CACHE_THUMBS, config->cache_thumbs_keep_days); crop_dir(config->cachedir, DIR_CACHE_MISC, config->cache_misc_keep_days); } /** * Crops the caches - * @param cachedir covercache directory - * @param keepdays delete files older than this number of days - * @return deleted file count on success, else -1 + * @param config pointer to static config */ void cache_disk_crop(struct t_config *config) { - crop_dir(config->cachedir, DIR_CACHE_COVER, 0); - crop_dir(config->cachedir, DIR_CACHE_LYRICS, 0); + if (config->cache_cover_keep_days > CACHE_DISK_DISABLED) { + crop_dir(config->cachedir, DIR_CACHE_COVER, 0); + } + if (config->cache_lyrics_keep_days > CACHE_DISK_DISABLED) { + crop_dir(config->cachedir, DIR_CACHE_LYRICS, 0); + } + if (config->cache_thumbs_keep_days > CACHE_DISK_DISABLED) { + crop_dir(config->cachedir, DIR_CACHE_THUMBS, 0); + } crop_dir(config->cachedir, DIR_CACHE_MISC, 0); - crop_dir(config->cachedir, DIR_CACHE_THUMBS, 0); } /** diff --git a/src/mympd_api/timer_handlers.c b/src/mympd_api/timer_handlers.c index 653921e4b..e2138f230 100644 --- a/src/mympd_api/timer_handlers.c +++ b/src/mympd_api/timer_handlers.c @@ -29,7 +29,7 @@ * Private definitions */ -static void timer_handler_covercache_crop(void); +static void timer_handler_cache_disk_crop(void); static void timer_handler_smartpls_update(void); static void timer_handler_caches_create(void); @@ -46,7 +46,7 @@ void timer_handler_by_id(unsigned timer_id, struct t_timer_definition *definitio (void) definition; // not used switch(timer_id) { case TIMER_ID_DISK_CACHE_CROP: - timer_handler_covercache_crop(); + timer_handler_cache_disk_crop(); break; case TIMER_ID_SMARTPLS_UPDATE: timer_handler_smartpls_update(); @@ -183,10 +183,10 @@ bool mympd_api_timer_startplay(struct t_partition_state *partition_state, */ /** - * Timer handler for timer_id TIMER_ID_COVERCACHE_CROP + * Timer handler for timer_id TIMER_ID_DISK_CACHE_CROP */ -static void timer_handler_covercache_crop(void) { - MYMPD_LOG_INFO(NULL, "Start timer_handler_covercache_crop"); +static void timer_handler_cache_disk_crop(void) { + MYMPD_LOG_INFO(NULL, "Start timer_handler_cache_disk_crop"); struct t_work_request *request = create_request(REQUEST_TYPE_DISCARD, 0, 0, MYMPD_API_CACHE_DISK_CROP, NULL, MPD_PARTITION_DEFAULT); request->data = jsonrpc_end(request->data); push_request(request, 0);