return 0;
}
- if ((ret = mail_cache_reopen(cache)) <= 0) {
- /* error / we already have the latest file open */
+ if (!mail_cache_need_reopen(cache))
+ return 0;
+ else if ((ret = mail_cache_reopen(cache)) <= 0) {
+ /* error / corrupted */
return ret;
}
}
(and deleted), -1 if I/O error. */
int mail_cache_map_all(struct mail_cache *cache);
void mail_cache_file_close(struct mail_cache *cache);
+bool mail_cache_need_reopen(struct mail_cache *cache);
int mail_cache_reopen(struct mail_cache *cache);
/* Notify the decision handling code that field was looked up for seq.
return 1;
}
-static bool mail_cache_need_reopen(struct mail_cache *cache)
+bool mail_cache_need_reopen(struct mail_cache *cache)
{
struct stat st;
return FALSE;
}
-static int mail_cache_reopen_now(struct mail_cache *cache)
+int mail_cache_reopen(struct mail_cache *cache)
{
struct mail_index_view *view;
const struct mail_index_ext *ext;
return 1;
}
-int mail_cache_reopen(struct mail_cache *cache)
-{
- i_assert(!cache->locked);
-
- if (!mail_cache_need_reopen(cache)) {
- /* reopening does no good */
- return 0;
- }
- return mail_cache_reopen_now(cache);
-}
-
static void mail_cache_update_need_compress(struct mail_cache *cache)
{
const struct mail_index_cache_optimization_settings *set =
/* locked the latest file */
break;
}
- if (mail_cache_reopen_now(cache) <= 0) {
+ if (mail_cache_reopen(cache) <= 0) {
i_assert(cache->file_lock == NULL);
return -1;
}