diff options
-rw-r--r-- | apps/root_menu.c | 59 | ||||
-rw-r--r-- | apps/tagcache.c | 4 | ||||
-rw-r--r-- | apps/tagcache.h | 1 |
3 files changed, 35 insertions, 29 deletions
diff --git a/apps/root_menu.c b/apps/root_menu.c index fa00a06ed5..b9847dfd54 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c | |||
@@ -104,35 +104,17 @@ static int browser(void* param) | |||
104 | case GO_TO_DBBROWSER: | 104 | case GO_TO_DBBROWSER: |
105 | if (!tagcache_is_usable()) | 105 | if (!tagcache_is_usable()) |
106 | { | 106 | { |
107 | /* Check if we're still initialising, so status is unknown */ | 107 | bool reinit_attempted = false; |
108 | struct tagcache_stat *stat = tagcache_get_stat(); | ||
109 | if (!stat->initialized) | ||
110 | { | ||
111 | gui_syncsplash(HZ*2, true, str(LANG_TAGCACHE_BUSY)); | ||
112 | return GO_TO_PREVIOUS; | ||
113 | } | ||
114 | |||
115 | /* Re-init if required */ | ||
116 | if (!stat->ready && !stat->commit_delayed && stat->processed_entries == 0) | ||
117 | { | ||
118 | /* Prompt the user */ | ||
119 | char *lines[]={str(LANG_TAGCACHE_BUSY), str(LANG_TAGCACHE_FORCE_UPDATE)}; | ||
120 | struct text_message message={lines, 2}; | ||
121 | if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_NO) | ||
122 | return GO_TO_PREVIOUS; | ||
123 | int i; | ||
124 | FOR_NB_SCREENS(i) | ||
125 | screens[i].clear_display(); | ||
126 | |||
127 | /* Start initialisation */ | ||
128 | tagcache_rebuild(); | ||
129 | } | ||
130 | 108 | ||
131 | /* Now display progress until it's ready or the user exits */ | 109 | /* Now display progress until it's ready or the user exits */ |
132 | while(!tagcache_is_usable()) | 110 | while(!tagcache_is_usable()) |
133 | { | 111 | { |
134 | gui_syncstatusbar_draw(&statusbars, false); | 112 | gui_syncstatusbar_draw(&statusbars, false); |
135 | stat = tagcache_get_stat(); | 113 | struct tagcache_stat *stat = tagcache_get_stat(); |
114 | |||
115 | /* Allow user to exit */ | ||
116 | if (action_userabort(HZ/2)) | ||
117 | break; | ||
136 | 118 | ||
137 | /* Maybe just needs to reboot due to delayed commit */ | 119 | /* Maybe just needs to reboot due to delayed commit */ |
138 | if (stat->commit_delayed) | 120 | if (stat->commit_delayed) |
@@ -141,6 +123,31 @@ static int browser(void* param) | |||
141 | break; | 123 | break; |
142 | } | 124 | } |
143 | 125 | ||
126 | /* Check if ready status is known */ | ||
127 | if (!stat->readyvalid) | ||
128 | { | ||
129 | gui_syncsplash(0, true, str(LANG_TAGCACHE_BUSY)); | ||
130 | continue; | ||
131 | } | ||
132 | |||
133 | /* Re-init if required */ | ||
134 | if (!reinit_attempted && !stat->ready && | ||
135 | stat->processed_entries == 0 && stat->commit_step == 0) | ||
136 | { | ||
137 | /* Prompt the user */ | ||
138 | reinit_attempted = true; | ||
139 | char *lines[]={str(LANG_TAGCACHE_BUSY), str(LANG_TAGCACHE_FORCE_UPDATE)}; | ||
140 | struct text_message message={lines, 2}; | ||
141 | if(gui_syncyesno_run(&message, NULL, NULL) == YESNO_NO) | ||
142 | break; | ||
143 | int i; | ||
144 | FOR_NB_SCREENS(i) | ||
145 | screens[i].clear_display(); | ||
146 | |||
147 | /* Start initialisation */ | ||
148 | tagcache_rebuild(); | ||
149 | } | ||
150 | |||
144 | /* Display building progress */ | 151 | /* Display building progress */ |
145 | if (stat->commit_step > 0) | 152 | if (stat->commit_step > 0) |
146 | { | 153 | { |
@@ -153,10 +160,6 @@ static int browser(void* param) | |||
153 | gui_syncsplash(0, true, str(LANG_BUILDING_DATABASE), | 160 | gui_syncsplash(0, true, str(LANG_BUILDING_DATABASE), |
154 | stat->processed_entries); | 161 | stat->processed_entries); |
155 | } | 162 | } |
156 | |||
157 | /* Allow user to exit */ | ||
158 | if (action_userabort(HZ/2)) | ||
159 | break; | ||
160 | } | 163 | } |
161 | } | 164 | } |
162 | if (!tagcache_is_usable()) | 165 | if (!tagcache_is_usable()) |
diff --git a/apps/tagcache.c b/apps/tagcache.c index a899ff91fd..efa615675e 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -2617,6 +2617,7 @@ static bool commit(void) | |||
2617 | logf("tagcache committed"); | 2617 | logf("tagcache committed"); |
2618 | remove(TAGCACHE_FILE_TEMP); | 2618 | remove(TAGCACHE_FILE_TEMP); |
2619 | tc_stat.ready = check_all_headers(); | 2619 | tc_stat.ready = check_all_headers(); |
2620 | tc_stat.readyvalid = true; | ||
2620 | 2621 | ||
2621 | if (local_allocation) | 2622 | if (local_allocation) |
2622 | { | 2623 | { |
@@ -3770,6 +3771,7 @@ static void tagcache_thread(void) | |||
3770 | /* Don't delay bootup with the header check but do it on background. */ | 3771 | /* Don't delay bootup with the header check but do it on background. */ |
3771 | sleep(HZ); | 3772 | sleep(HZ); |
3772 | tc_stat.ready = check_all_headers(); | 3773 | tc_stat.ready = check_all_headers(); |
3774 | tc_stat.readyvalid = true; | ||
3773 | 3775 | ||
3774 | while (1) | 3776 | while (1) |
3775 | { | 3777 | { |
@@ -3972,6 +3974,6 @@ int tagcache_get_commit_step(void) | |||
3972 | } | 3974 | } |
3973 | int tagcache_get_max_commit_step(void) | 3975 | int tagcache_get_max_commit_step(void) |
3974 | { | 3976 | { |
3975 | return 8; /* To be written, better hard-coded here than in the UI */ | 3977 | return (int)(sizeof(sorted_tags)/sizeof(sorted_tags[0]))+1; |
3976 | } | 3978 | } |
3977 | 3979 | ||
diff --git a/apps/tagcache.h b/apps/tagcache.h index c8d52308ce..0cfdedf310 100644 --- a/apps/tagcache.h +++ b/apps/tagcache.h | |||
@@ -86,6 +86,7 @@ enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq, | |||
86 | 86 | ||
87 | struct tagcache_stat { | 87 | struct tagcache_stat { |
88 | bool initialized; /* Is tagcache currently busy? */ | 88 | bool initialized; /* Is tagcache currently busy? */ |
89 | bool readyvalid; /* Has tagcache ready status been ascertained */ | ||
89 | bool ready; /* Is tagcache ready to be used? */ | 90 | bool ready; /* Is tagcache ready to be used? */ |
90 | bool ramcache; /* Is tagcache loaded in ram? */ | 91 | bool ramcache; /* Is tagcache loaded in ram? */ |
91 | bool commit_delayed; /* Has commit been delayed until next reboot? */ | 92 | bool commit_delayed; /* Has commit been delayed until next reboot? */ |