if (ctx->offset == 0) {
/* end of this record list. check newly appended data. */
if (view->trans_seq1 > ctx->seq ||
- view->trans_seq2 < ctx->seq ||
- MAIL_CACHE_IS_UNUSABLE(view->cache))
+ view->trans_seq2 < ctx->seq)
return 0;
- /* check data still in memory */
+ /* check data still in memory. this works for recent mails
+ even with INDEX=MEMORY */
if (!ctx->memory_appends_checked) {
if (mail_cache_lookup_iter_transaction(ctx))
return 1;
ctx->memory_appends_checked = TRUE;
}
+ if (MAIL_CACHE_IS_UNUSABLE(view->cache))
+ return 0;
/* check data already written to cache file */
if (ctx->disk_appends_checked ||
struct mail_cache *cache = ctx->cache;
int ret;
+ if (MAIL_INDEX_IS_IN_MEMORY(cache->index)) {
+ if (cache->file_fields_count <= field_idx) {
+ cache->file_field_map =
+ i_realloc(cache->file_field_map,
+ cache->file_fields_count *
+ sizeof(unsigned int),
+ (field_idx+1) * sizeof(unsigned int));
+ cache->file_fields_count = field_idx+1;
+ }
+ cache->file_field_map[field_idx] = field_idx;
+ cache->field_file_map[field_idx] = field_idx;
+ return 0;
+ }
+
if (mail_cache_transaction_lock(ctx) <= 0) {
if (MAIL_CACHE_IS_UNUSABLE(cache))
return -1;
if (ret < 0)
return;
- if (ctx->cache_file_seq == 0)
- ctx->cache_file_seq = ctx->cache->hdr->file_seq;
+ if (ctx->cache_file_seq == 0) {
+ if (MAIL_INDEX_IS_IN_MEMORY(ctx->cache->index))
+ ctx->cache_file_seq = 1;
+ else
+ ctx->cache_file_seq = ctx->cache->hdr->file_seq;
+ }
file_field = ctx->cache->field_file_map[field_idx];
i_assert(file_field != (uint32_t)-1);