/* These two functions are called by the USB and shutdown handlers */ void tree_flush(void) { #ifdef HAVE_TAGCACHE tagcache_shutdown(); #endif #ifdef HAVE_TC_RAMCACHE tagcache_unload_ramcache(); #endif #ifdef HAVE_DIRCACHE { int old_val = global_status.dircache_size; if (global_settings.dircache) { if (!dircache_is_initializing()) global_status.dircache_size = dircache_get_cache_size(); # ifdef HAVE_EEPROM_SETTINGS if (firmware_settings.initialized) dircache_save(); # endif dircache_disable(); } else { global_status.dircache_size = 0; } if (old_val != global_status.dircache_size) status_save(); } #endif }
static int init_dircache(bool preinit) { #ifdef HAVE_DIRCACHE int result = 0; bool clear = false; if (preinit) dircache_init(); if (!global_settings.dircache) return 0; # ifdef HAVE_EEPROM_SETTINGS if (firmware_settings.initialized && firmware_settings.disk_clean && preinit) { result = dircache_load(); if (result < 0) { firmware_settings.disk_clean = false; if (global_status.dircache_size <= 0) { /* This will be in default language, settings are not applied yet. Not really any easy way to fix that. */ splash(0, str(LANG_SCANNING_DISK)); clear = true; } dircache_build(global_status.dircache_size); } } else # endif { if (preinit) return -1; if (!dircache_is_enabled() && !dircache_is_initializing()) { if (global_status.dircache_size <= 0) { splash(0, str(LANG_SCANNING_DISK)); clear = true; } result = dircache_build(global_status.dircache_size); } if (result < 0) { /* Initialization of dircache failed. Manual action is * necessary to enable dircache again. */ splashf(0, "Dircache failed, disabled. Result: %d", result); global_settings.dircache = false; } } if (clear) { backlight_on(); show_logo(); global_status.dircache_size = dircache_get_cache_size(); status_save(); } return result; #else (void)preinit; return 0; #endif }