plugins: Disk Tidy: wait for dircache

Running Disk Tidy while the dircache is loading is a lot
slower than waiting for it to finish building first.

Typical scenarios for this would be starting Disk Tidy
immediately after booting or after unplugging from USB.

Deleting files during a dircache build also seems to easily
result in memory corruption, as evidenced by visual glitches
appearing in the theme.

Change-Id: I9250d918d916b112ffe2504a9225a0b52bcc3622
This commit is contained in:
Christian Soffke 2025-12-20 06:06:05 +01:00
parent 8e512d1f79
commit f7ede2b9df
3 changed files with 10 additions and 0 deletions

View file

@ -871,6 +871,9 @@ static const struct plugin_api rockbox_api = {
#endif
strstr,
sb_set_title_text,
#ifdef HAVE_DIRCACHE
dircache_wait,
#endif
};
static int plugin_buffer_handle;

View file

@ -1022,6 +1022,9 @@ struct plugin_api {
#endif
char* (*strstr)(const char *s1, const char *s2);
bool (*sb_set_title_text)(const char* title, enum themable_icons icon, enum screen_type screen);
#ifdef HAVE_DIRCACHE
void (*dircache_wait)(void);
#endif
};
/* plugin header */

View file

@ -734,6 +734,10 @@ static enum plugin_status tidy_lcd_menu(void)
switch(rb->do_menu(&menu, &selection, NULL, false)) {
case 0:
if (tidy_types_selected()) {
#ifdef HAVE_DIRCACHE
rb->splash(0, ID2P(LANG_WAIT));
rb->dircache_wait();
#endif
disktidy_status = tidy_do();
if (disktidy_status == PLUGIN_OK)
disktidy_status = display_run_stats();