diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/main.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/apps/main.c b/apps/main.c index a3fe8ef64f..c21accb2aa 100644 --- a/apps/main.c +++ b/apps/main.c | |||
@@ -109,29 +109,57 @@ void app_main(void) | |||
109 | browse_root(); | 109 | browse_root(); |
110 | } | 110 | } |
111 | 111 | ||
112 | int init_dircache(void) | 112 | int init_dircache(bool preinit) |
113 | { | 113 | { |
114 | #ifdef HAVE_DIRCACHE | 114 | #ifdef HAVE_DIRCACHE |
115 | int result = 0; | 115 | int result = 0; |
116 | bool clear = false; | ||
117 | |||
118 | if (preinit) | ||
119 | dircache_init(); | ||
116 | 120 | ||
117 | dircache_init(); | ||
118 | if (global_settings.dircache) | 121 | if (global_settings.dircache) |
119 | { | 122 | { |
120 | # ifdef HAVE_EEPROM | 123 | # ifdef HAVE_EEPROM |
121 | if (firmware_settings.initialized && firmware_settings.disk_clean) | 124 | if (firmware_settings.initialized && firmware_settings.disk_clean |
125 | && preinit) | ||
122 | { | 126 | { |
123 | result = dircache_load(DIRCACHE_FILE); | 127 | result = dircache_load(DIRCACHE_FILE); |
124 | remove(DIRCACHE_FILE); | 128 | remove(DIRCACHE_FILE); |
125 | if (result == 0) | 129 | if (result < 0) |
126 | return 0; | 130 | firmware_settings.disk_clean = false; |
131 | |||
132 | return result; | ||
127 | } | 133 | } |
128 | # endif | 134 | # endif |
129 | 135 | ||
130 | result = dircache_build(global_settings.dircache_size); | 136 | if (preinit) |
137 | return -1; | ||
138 | |||
139 | if (!dircache_is_enabled() | ||
140 | && !dircache_is_initializing()) | ||
141 | { | ||
142 | if (global_settings.dircache_size <= 0) | ||
143 | { | ||
144 | gui_syncsplash(0, true, str(LANG_DIRCACHE_BUILDING)); | ||
145 | clear = true; | ||
146 | } | ||
147 | result = dircache_build(global_settings.dircache_size); | ||
148 | } | ||
149 | |||
150 | if (result < 0) | ||
151 | gui_syncsplash(0, true, "Failed! Result: %d", result); | ||
152 | |||
153 | if (clear) | ||
154 | { | ||
155 | backlight_on(); | ||
156 | show_logo(); | ||
157 | } | ||
131 | } | 158 | } |
132 | 159 | ||
133 | return result; | 160 | return result; |
134 | #else | 161 | #else |
162 | (void)preinit; | ||
135 | return 0; | 163 | return 0; |
136 | #endif | 164 | #endif |
137 | } | 165 | } |
@@ -195,7 +223,8 @@ void init(void) | |||
195 | settings_load(SETTINGS_ALL); | 223 | settings_load(SETTINGS_ALL); |
196 | gui_sync_wps_init(); | 224 | gui_sync_wps_init(); |
197 | settings_apply(); | 225 | settings_apply(); |
198 | init_dircache(); | 226 | init_dircache(true); |
227 | init_dircache(false); | ||
199 | init_tagcache(); | 228 | init_tagcache(); |
200 | sleep(HZ/2); | 229 | sleep(HZ/2); |
201 | tree_init(); | 230 | tree_init(); |
@@ -401,11 +430,14 @@ void init(void) | |||
401 | settings_load(SETTINGS_ALL); | 430 | settings_load(SETTINGS_ALL); |
402 | 431 | ||
403 | 432 | ||
404 | init_dircache(); | 433 | if (init_dircache(true) < 0) |
434 | { | ||
435 | remove(TAGCACHE_STATEFILE); | ||
436 | } | ||
405 | 437 | ||
406 | gui_sync_wps_init(); | 438 | gui_sync_wps_init(); |
407 | settings_apply(); | 439 | settings_apply(); |
408 | //init_dircache(); | 440 | init_dircache(false); |
409 | init_tagcache(); | 441 | init_tagcache(); |
410 | 442 | ||
411 | #ifdef HAVE_EEPROM | 443 | #ifdef HAVE_EEPROM |