Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2830:f71de5c12419 HEAD
last fix was wrong
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 26 Oct 2004 01:10:33 +0300 |
parents | d1bae4aa3f80 |
children | 909ac8c9039d |
files | src/lib-storage/index/mbox/mbox-sync.c |
diffstat | 1 files changed, 10 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-sync.c Tue Oct 26 00:55:15 2004 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync.c Tue Oct 26 01:10:33 2004 +0300 @@ -603,7 +603,7 @@ mbox_sync_handle_missing_space(struct mbox_sync_mail_context *mail_ctx) { struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx; - uoff_t end_offset, move_diff, extra_space; + uoff_t end_offset, move_diff, extra_space, needed_space; uint32_t last_seq; buffer_append(sync_ctx->mails, &mail_ctx->mail, sizeof(mail_ctx->mail)); @@ -620,15 +620,18 @@ /* we have enough space now */ if (mail_ctx->mail.uid == 0) { - /* this message was expunged. fill more or less of the space. */ + /* this message was expunged. fill more or less of the space. + space_diff now consists of a negative "bytes needed" sum, + plus the expunged space of this message. so it contains how + many bytes of _extra_ space we have. */ extra_space = MBOX_HEADER_PADDING * (sync_ctx->seq - sync_ctx->need_space_seq + 1); - if ((uoff_t)sync_ctx->space_diff > extra_space) { + needed_space = mail_ctx->mail.space - sync_ctx->space_diff; + if ((uoff_t)sync_ctx->space_diff > needed_space + extra_space) { /* don't waste too much on padding */ - i_assert(mail_ctx->mail.space > (off_t)extra_space); - sync_ctx->expunged_space = - mail_ctx->mail.space - extra_space; - sync_ctx->space_diff = extra_space; + sync_ctx->expunged_space = mail_ctx->mail.space - + (needed_space + extra_space); + sync_ctx->space_diff = needed_space + extra_space; } else { extra_space = sync_ctx->space_diff; }