Mercurial > dovecot > core-2.2
changeset 4331:b445c43d5472 HEAD
Allow reading saved mails which haven't been committed yet (ie. make quota
plugin work).
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 12 Jun 2006 11:24:44 +0300 |
parents | 823648215520 |
children | 2428e6821eb4 |
files | src/lib-storage/index/dbox/dbox-file.c src/lib-storage/index/dbox/dbox-file.h src/lib-storage/index/dbox/dbox-mail.c src/lib-storage/index/dbox/dbox-save.c src/lib-storage/index/dbox/dbox-storage.h src/lib-storage/index/dbox/dbox-sync-expunge.c src/lib-storage/index/dbox/dbox-sync-full.c src/lib-storage/index/dbox/dbox-sync.c |
diffstat | 8 files changed, 26 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox/dbox-file.c Sun Jun 11 20:39:04 2006 +0300 +++ b/src/lib-storage/index/dbox/dbox-file.c Mon Jun 12 11:24:44 2006 +0300 @@ -101,7 +101,8 @@ return 1; } -int dbox_file_seek(struct dbox_mailbox *mbox, uint32_t file_seq, uoff_t offset) +int dbox_file_seek(struct dbox_mailbox *mbox, uint32_t file_seq, uoff_t offset, + bool ignore_zero_uid) { int ret; @@ -148,7 +149,8 @@ if ((ret = dbox_file_read_mail_header(mbox, mbox->file, offset)) <= 0) return ret; - if (mbox->file->seeked_mail_size == 0 || mbox->file->seeked_uid == 0) { + if (mbox->file->seeked_mail_size == 0 || + (mbox->file->seeked_uid == 0 && !ignore_zero_uid)) { /* could be legitimately just not written yet. we're at EOF. */ return 0; } @@ -166,7 +168,7 @@ mbox->file->mail_header_size + mbox->file->seeked_mail_size; - ret = dbox_file_seek(mbox, mbox->file->file_seq, offset); + ret = dbox_file_seek(mbox, mbox->file->file_seq, offset, FALSE); if (ret <= 0) return ret;
--- a/src/lib-storage/index/dbox/dbox-file.h Sun Jun 11 20:39:04 2006 +0300 +++ b/src/lib-storage/index/dbox/dbox-file.h Mon Jun 12 11:24:44 2006 +0300 @@ -13,8 +13,8 @@ void dbox_file_close(struct dbox_file *file); /* Returns -1 = error, 0 = EOF (mail was just moved / file broken), 1 = ok */ -int dbox_file_seek(struct dbox_mailbox *mbox, - uint32_t file_seq, uoff_t offset); +int dbox_file_seek(struct dbox_mailbox *mbox, uint32_t file_seq, uoff_t offset, + bool ignore_zero_uid); int dbox_file_seek_next_nonexpunged(struct dbox_mailbox *mbox); void dbox_file_header_init(struct dbox_file_header *hdr);
--- a/src/lib-storage/index/dbox/dbox-mail.c Sun Jun 11 20:39:04 2006 +0300 +++ b/src/lib-storage/index/dbox/dbox-mail.c Mon Jun 12 11:24:44 2006 +0300 @@ -77,6 +77,8 @@ int *ret_r) { struct dbox_mailbox *mbox = (struct dbox_mailbox *)mail->ibox; + struct dbox_transaction_context *t = + (struct dbox_transaction_context *)mail->trans; uint32_t seq = mail->mail.mail.seq; *ret_r = dbox_mail_lookup_offset(mail->trans, seq, @@ -87,7 +89,8 @@ return TRUE; } - if ((*ret_r = dbox_file_seek(mbox, *file_seq_r, *offset_r)) < 0) + if ((*ret_r = dbox_file_seek(mbox, *file_seq_r, *offset_r, + seq >= t->first_saved_mail_seq)) < 0) return TRUE; if (*ret_r > 0) { /* ok */
--- a/src/lib-storage/index/dbox/dbox-save.c Sun Jun 11 20:39:04 2006 +0300 +++ b/src/lib-storage/index/dbox/dbox-save.c Mon Jun 12 11:24:44 2006 +0300 @@ -23,7 +23,6 @@ struct mail_index_transaction *trans; struct dbox_uidlist_append_ctx *append_ctx; - uint32_t first_append_seq; struct mail_index_sync_ctx *index_sync_ctx; /* updated for each appended mail: */ @@ -230,8 +229,8 @@ if (mail_set_seq(dest_mail, ctx->seq) < 0) i_unreached(); - if (ctx->first_append_seq == 0) - ctx->first_append_seq = ctx->seq; + if (t->first_saved_mail_seq == 0) + t->first_saved_mail_seq = ctx->seq; t_pop(); *ctx_r = &ctx->ctx; @@ -313,8 +312,8 @@ int dbox_transaction_save_commit_pre(struct dbox_save_context *ctx) { - struct index_transaction_context *idx_trans = - (struct index_transaction_context *)ctx->ctx.transaction; + struct dbox_transaction_context *t = + (struct dbox_transaction_context *)ctx->ctx.transaction; struct dbox_mail_header hdr; struct dbox_file *file; struct mail_index_view *view; @@ -348,8 +347,8 @@ mail_index_append_assign_uids(ctx->trans, uid, &last_uid); /* update UIDs */ - for (seq = ctx->first_append_seq; seq <= ctx->seq; seq++, uid++) { - ret = dbox_mail_lookup_offset(idx_trans, seq, + for (seq = t->first_saved_mail_seq; seq <= ctx->seq; seq++, uid++) { + ret = dbox_mail_lookup_offset(&t->ictx, seq, &file_seq, &offset); i_assert(ret > 0); /* it's in memory, shouldn't fail! */
--- a/src/lib-storage/index/dbox/dbox-storage.h Sun Jun 11 20:39:04 2006 +0300 +++ b/src/lib-storage/index/dbox/dbox-storage.h Mon Jun 12 11:24:44 2006 +0300 @@ -70,6 +70,7 @@ struct dbox_transaction_context { struct index_transaction_context ictx; + uint32_t first_saved_mail_seq; struct dbox_save_context *save_ctx; };
--- a/src/lib-storage/index/dbox/dbox-sync-expunge.c Sun Jun 11 20:39:04 2006 +0300 +++ b/src/lib-storage/index/dbox/dbox-sync-expunge.c Mon Jun 12 11:24:44 2006 +0300 @@ -90,13 +90,13 @@ uoff_t full_size; off_t bytes; - ret = dbox_file_seek(mbox, orig_entry->file_seq, orig_offset); + ret = dbox_file_seek(mbox, orig_entry->file_seq, orig_offset, FALSE); if (ret >= 0 && mbox->file->hdr.have_expunged_mails != '0') { /* there are some expunged mails in the file, go through all of the mails. */ ret = dbox_file_seek(mbox, orig_entry->file_seq, - mbox->file->header_size); + mbox->file->header_size, FALSE); } /* skip mails until we find the first we don't want expunged */ @@ -379,7 +379,7 @@ } /* mails expunged from the end of file, ftruncate() it */ - ret = dbox_file_seek(mbox, entry->file_seq, offset); + ret = dbox_file_seek(mbox, entry->file_seq, offset, FALSE); if (ret <= 0) { if (ret < 0) return -1;
--- a/src/lib-storage/index/dbox/dbox-sync-full.c Sun Jun 11 20:39:04 2006 +0300 +++ b/src/lib-storage/index/dbox/dbox-sync-full.c Mon Jun 12 11:24:44 2006 +0300 @@ -116,7 +116,7 @@ uint32_t seq; int ret; - if ((ret = dbox_file_seek(mbox, file_seq, 0)) < 0) { + if ((ret = dbox_file_seek(mbox, file_seq, 0, FALSE)) < 0) { /* error / broken file */ return -1; }
--- a/src/lib-storage/index/dbox/dbox-sync.c Sun Jun 11 20:39:04 2006 +0300 +++ b/src/lib-storage/index/dbox/dbox-sync.c Mon Jun 12 11:24:44 2006 +0300 @@ -170,7 +170,7 @@ return -1; } - if ((ret = dbox_file_seek(mbox, file_seq, offset)) <= 0) + if ((ret = dbox_file_seek(mbox, file_seq, offset, FALSE)) <= 0) return ret; while (mbox->file->seeked_uid <= uid2) { @@ -257,7 +257,7 @@ unsigned char keyword_array, keyword_mask = 1; unsigned int file_idx, first_flag_offset; - if (dbox_file_seek(ctx->mbox, entry->file_seq, 0) <= 0) + if (dbox_file_seek(ctx->mbox, entry->file_seq, 0, FALSE) <= 0) return -1; keyword_array = set ? '1' : '0'; @@ -287,7 +287,7 @@ unsigned int first_flag_offset; int ret; - if (dbox_file_seek(ctx->mbox, entry->file_seq, 0) <= 0) + if (dbox_file_seek(ctx->mbox, entry->file_seq, 0, FALSE) <= 0) return -1; if (ctx->mbox->file->keyword_count == 0) @@ -318,7 +318,7 @@ unsigned int count, file_idx, keyword_idx; int ret = 0; - if (dbox_file_seek(ctx->mbox, entry->file_seq, 0) <= 0) + if (dbox_file_seek(ctx->mbox, entry->file_seq, 0, FALSE) <= 0) return -1; /* Get a list of all new keywords. Using seq_range is the easiest