diff options
author | William Wilgus <wilgus.william@gmail.com> | 2023-09-24 22:00:23 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2023-10-01 11:51:38 -0400 |
commit | 1c47722226870023bf422d451527d86774900e1b (patch) | |
tree | c87e4c8764be8432af797f54629ddafbaf1ec402 /apps/tagcache.c | |
parent | 7ccbd705f43553ff358d6713c8d6ac7cc9e3c343 (diff) | |
download | rockbox-1c47722226870023bf422d451527d86774900e1b.tar.gz rockbox-1c47722226870023bf422d451527d86774900e1b.zip |
[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
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r-- | apps/tagcache.c | 33 |
1 files changed, 28 insertions, 5 deletions
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 @@ | |||
75 | #include "usb.h" | 75 | #include "usb.h" |
76 | #include "metadata.h" | 76 | #include "metadata.h" |
77 | #include "tagcache.h" | 77 | #include "tagcache.h" |
78 | #include "yesno.h" | ||
78 | #include "core_alloc.h" | 79 | #include "core_alloc.h" |
79 | #include "crc32.h" | 80 | #include "crc32.h" |
80 | #include "misc.h" | 81 | #include "misc.h" |
@@ -5064,17 +5065,39 @@ void tagcache_unload_ramcache(void) | |||
5064 | #endif /* HAVE_TC_RAMCACHE */ | 5065 | #endif /* HAVE_TC_RAMCACHE */ |
5065 | 5066 | ||
5066 | #ifndef __PCTOOL__ | 5067 | #ifndef __PCTOOL__ |
5068 | |||
5069 | /* | ||
5070 | * db_file_exists is noinline to minimize stack usage | ||
5071 | */ | ||
5072 | static bool NO_INLINE db_file_exists(const char* filename) | ||
5073 | { | ||
5074 | char buf[MAX_PATH]; | ||
5075 | |||
5076 | snprintf(buf, sizeof(buf), "%s/%s", tc_stat.db_path, filename); | ||
5077 | |||
5078 | return file_exists(buf); | ||
5079 | } | ||
5080 | |||
5067 | static void tagcache_thread(void) | 5081 | static void tagcache_thread(void) |
5068 | { | 5082 | { |
5069 | struct queue_event ev; | 5083 | struct queue_event ev; |
5070 | bool check_done = false; | 5084 | bool check_done = false; |
5071 | 5085 | cpu_boost(true); | |
5072 | /* If the previous cache build/update was interrupted, commit | 5086 | /* If the previous cache build/update was interrupted, commit |
5073 | * the changes first in foreground. */ | 5087 | * the changes first in foreground. */ |
5074 | cpu_boost(true); | 5088 | if (db_file_exists(TAGCACHE_FILE_TEMP)) |
5075 | allocate_tempbuf(); | 5089 | { |
5076 | commit(); | 5090 | static const char *lines[] = {ID2P(LANG_TAGCACHE_BUSY), |
5077 | free_tempbuf(); | 5091 | ID2P(LANG_TAGCACHE_UPDATE)}; |
5092 | static const struct text_message message = {lines, 2}; | ||
5093 | |||
5094 | if (gui_syncyesno_run_w_tmo(HZ * 5, YESNO_YES, &message, NULL, NULL) == YESNO_YES) | ||
5095 | { | ||
5096 | allocate_tempbuf(); | ||
5097 | commit(); | ||
5098 | free_tempbuf(); | ||
5099 | } | ||
5100 | } | ||
5078 | 5101 | ||
5079 | #ifdef HAVE_TC_RAMCACHE | 5102 | #ifdef HAVE_TC_RAMCACHE |
5080 | #ifdef HAVE_EEPROM_SETTINGS | 5103 | #ifdef HAVE_EEPROM_SETTINGS |