mail_cache_copy(struct mail_cache *cache, struct mail_index_transaction *trans,
struct event *event, int fd, const char *reason,
uint32_t *file_seq_r, uoff_t *file_size_r, uint32_t *max_uid_r,
- ARRAY_TYPE(uint32_t) *ext_offsets)
+ uint32_t *ext_first_seq_r, ARRAY_TYPE(uint32_t) *ext_offsets)
{
struct mail_cache_copy_context ctx;
struct mail_cache_lookup_iterate_ctx iter;
i_assert(reason != NULL);
*max_uid_r = 0;
+ *ext_first_seq_r = 0;
/* get the latest info on fields */
if (mail_cache_header_fields_read(cache) < 0)
return -1;
- view = mail_index_transaction_get_view(trans);
+ view = mail_index_transaction_open_updated_view(trans);
cache_view = mail_cache_view_open(cache, view);
output = o_stream_create_fd_file(fd, 0, FALSE);
seq = trans->first_new_seq;
}
+ *ext_first_seq_r = seq;
i_array_init(ext_offsets, message_count); record_count = 0;
for (; seq <= message_count; seq++) {
if (mail_index_transaction_is_expunged(trans, seq)) {
o_stream_nsend(output, &hdr, sizeof(hdr));
mail_cache_view_close(&cache_view);
+ mail_index_view_close(&view);
if (o_stream_finish(output) < 0) {
mail_cache_set_syscall_error(cache, "write()");
{
struct event *event;
struct stat st;
- uint32_t prev_file_seq, file_seq, old_offset, max_uid;
+ uint32_t prev_file_seq, file_seq, old_offset, max_uid, ext_first_seq;
ARRAY_TYPE(uint32_t) ext_offsets;
const uint32_t *offsets;
uoff_t prev_file_size, file_size;
event_add_int(event, "prev_deleted_records", prev_deleted_records);
if (mail_cache_copy(cache, trans, event, fd, reason,
- &file_seq, &file_size, &max_uid, &ext_offsets) < 0)
+ &file_seq, &file_size, &max_uid,
+ &ext_first_seq, &ext_offsets) < 0)
return -1;
if (fstat(fd, &st) < 0) {
offsets = array_get(&ext_offsets, &count);
for (i = 0; i < count; i++) {
if (offsets[i] != 0) {
- mail_index_update_ext(trans, i + 1, cache->ext_id,
+ mail_index_update_ext(trans, ext_first_seq + i,
+ cache->ext_id,
&offsets[i], &old_offset);
}
}