static void dbox_sync_index_copy_cache(struct dbox_sync_rebuild_context *ctx, struct mail_index_view *view, uint32_t old_seq, uint32_t new_seq) { struct mail_index_map *map; const void *data; uint32_t reset_id; bool expunged; if (ctx->cache_ext_id == (uint32_t)-1) return; mail_index_lookup_ext_full(view, old_seq, ctx->cache_ext_id, &map, &data, &expunged); if (expunged) return; if (!mail_index_ext_get_reset_id(view, map, ctx->cache_ext_id, &reset_id) || reset_id == 0) return; if (!ctx->cache_used) { /* set reset id */ ctx->cache_used = TRUE; ctx->cache_reset_id = reset_id; mail_index_ext_reset(ctx->trans, ctx->cache_ext_id, ctx->cache_reset_id, TRUE); } if (ctx->cache_reset_id == reset_id) { mail_index_update_ext(ctx->trans, new_seq, ctx->cache_ext_id, data, NULL); } }
uint32_t mail_cache_lookup_cur_offset(struct mail_index_view *view, uint32_t seq, uint32_t *reset_id_r) { struct mail_cache *cache = mail_index_view_get_index(view)->cache; struct mail_index_map *map; const void *data; uint32_t offset; mail_index_lookup_ext_full(view, seq, cache->ext_id, &map, &data, NULL); if (data == NULL) { /* no cache offsets */ return 0; } offset = *((const uint32_t *)data); if (offset == 0) return 0; if (!mail_index_ext_get_reset_id(view, map, cache->ext_id, reset_id_r)) i_unreached(); return offset; }