From 1c47722226870023bf422d451527d86774900e1b Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sun, 24 Sep 2023 22:00:23 -0400 Subject: [Feature] add a prompt to database commit on start-up adds a new function: gui_syncyesno_run_w_tmo(ticks, tmo_default_res, main_msg,yes_msg, no_msg) when a database needs committed on start-up a yes no prompt will appear if not answered within 5 seconds it defaults to Yes if instead you choose No next start-up you will be asked again you could rebuild the db still and waste time but it wouldn't hurt anything so I don't think that path needs blocked Change-Id: I58411f6e6bfebb6f142d99f33a1e8885ae7785c1 --- apps/tagcache.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'apps/tagcache.c') diff --git a/apps/tagcache.c b/apps/tagcache.c index 6abf957bc2..f7746f1ec3 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -75,6 +75,7 @@ #include "usb.h" #include "metadata.h" #include "tagcache.h" +#include "yesno.h" #include "core_alloc.h" #include "crc32.h" #include "misc.h" @@ -5064,17 +5065,39 @@ void tagcache_unload_ramcache(void) #endif /* HAVE_TC_RAMCACHE */ #ifndef __PCTOOL__ + +/* + * db_file_exists is noinline to minimize stack usage + */ +static bool NO_INLINE db_file_exists(const char* filename) +{ + char buf[MAX_PATH]; + + snprintf(buf, sizeof(buf), "%s/%s", tc_stat.db_path, filename); + + return file_exists(buf); +} + static void tagcache_thread(void) { struct queue_event ev; bool check_done = false; - + cpu_boost(true); /* If the previous cache build/update was interrupted, commit * the changes first in foreground. */ - cpu_boost(true); - allocate_tempbuf(); - commit(); - free_tempbuf(); + if (db_file_exists(TAGCACHE_FILE_TEMP)) + { + static const char *lines[] = {ID2P(LANG_TAGCACHE_BUSY), + ID2P(LANG_TAGCACHE_UPDATE)}; + static const struct text_message message = {lines, 2}; + + if (gui_syncyesno_run_w_tmo(HZ * 5, YESNO_YES, &message, NULL, NULL) == YESNO_YES) + { + allocate_tempbuf(); + commit(); + free_tempbuf(); + } + } #ifdef HAVE_TC_RAMCACHE #ifdef HAVE_EEPROM_SETTINGS -- cgit v1.2.3