Mercurial > dovecot > core-2.2
changeset 21166:147e0db09d7b
sdbox: Implement support for mail stubs
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Fri, 18 Nov 2016 15:17:08 +0200 |
parents | e912e661fa6f |
children | ad33af1307d6 |
files | src/lib-storage/index/dbox-common/dbox-save.c src/lib-storage/index/dbox-single/sdbox-save.c |
diffstat | 2 files changed, 41 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-common/dbox-save.c Fri Nov 18 15:16:27 2016 +0200 +++ b/src/lib-storage/index/dbox-common/dbox-save.c Fri Nov 18 15:17:08 2016 +0200 @@ -16,8 +16,12 @@ struct mail_save_data *mdata = &ctx->ctx.data; enum mail_flags save_flags; + if ((ctx->ctx.transaction->flags & MAILBOX_TRANSACTION_FLAG_FILL_IN_STUB) == 0) + mail_index_append(ctx->trans, mdata->uid, &ctx->seq); + else + ctx->seq = mdata->stub_seq; + save_flags = mdata->flags & ~MAIL_RECENT; - mail_index_append(ctx->trans, mdata->uid, &ctx->seq); mail_index_update_flags(ctx->trans, ctx->seq, MODIFY_REPLACE, save_flags); if (mdata->keywords != NULL) {
--- a/src/lib-storage/index/dbox-single/sdbox-save.c Fri Nov 18 15:16:27 2016 +0200 +++ b/src/lib-storage/index/dbox-single/sdbox-save.c Fri Nov 18 15:17:08 2016 +0200 @@ -258,6 +258,27 @@ return 0; } +static int dbox_save_assign_stub_uids(struct sdbox_save_context *ctx) +{ + struct dbox_file *const *files; + unsigned int i, count; + + files = array_get(&ctx->files, &count); + for (i = 0; i < count; i++) { + struct sdbox_file *sfile = (struct sdbox_file *)files[i]; + uint32_t uid; + + mail_index_lookup_uid(ctx->ctx.trans->view, + ctx->first_saved_seq + i, &uid); + i_assert(uid != 0); + + if (sdbox_file_assign_uid(sfile, uid) < 0) + return -1; + } + + return 0; +} + static void dbox_save_unref_files(struct sdbox_save_context *ctx) { struct dbox_file **files; @@ -301,13 +322,22 @@ dbox_save_update_header_flags(&ctx->ctx, ctx->sync_ctx->sync_view, ctx->mbox->hdr_ext_id, offsetof(struct sdbox_index_header, flags)); - /* assign UIDs for new messages */ hdr = mail_index_get_header(ctx->sync_ctx->sync_view); - mail_index_append_finish_uids(ctx->ctx.trans, hdr->next_uid, - &_t->changes->saved_uids); - if (dbox_save_assign_uids(ctx, &_t->changes->saved_uids) < 0) { - sdbox_transaction_save_rollback(_ctx); - return -1; + + if ((_ctx->transaction->flags & MAILBOX_TRANSACTION_FLAG_FILL_IN_STUB) == 0) { + /* assign UIDs for new messages */ + mail_index_append_finish_uids(ctx->ctx.trans, hdr->next_uid, + &_t->changes->saved_uids); + if (dbox_save_assign_uids(ctx, &_t->changes->saved_uids) < 0) { + sdbox_transaction_save_rollback(_ctx); + return -1; + } + } else { + /* assign UIDs that we stashed away */ + if (dbox_save_assign_stub_uids(ctx) < 0) { + sdbox_transaction_save_rollback(_ctx); + return -1; + } } if (ctx->ctx.mail != NULL)