Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6583:104a8929ef7c HEAD
When saving to empty mbox files, sync them first since it doesn't take
hardly any time anyway.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 21 Oct 2007 03:33:21 +0300 |
parents | 9e7bf6becfb4 |
children | 4fb613eb8ce9 |
files | src/lib-storage/index/mbox/mbox-save.c src/lib-storage/index/mbox/mbox-sync-private.h src/lib-storage/index/mbox/mbox-sync.c |
diffstat | 3 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-save.c Sun Oct 21 03:09:33 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-save.c Sun Oct 21 03:33:21 2007 +0300 @@ -267,6 +267,7 @@ { struct mbox_mailbox *mbox = ctx->mbox; struct mail_storage *storage = &mbox->storage->storage; + bool empty = FALSE; int ret; if (ctx->mbox->mbox_readonly) { @@ -300,7 +301,7 @@ } /* update mbox_sync_dirty state */ - ret = mbox_sync_has_changed(mbox, TRUE); + ret = mbox_sync_has_changed_full(mbox, TRUE, &empty); if (ret < 0) return -1; if (!want_mail && ret == 0) { @@ -311,7 +312,7 @@ } } - if (!ctx->synced && want_mail) { + if (!ctx->synced && (want_mail || empty)) { /* we'll need to assign UID for the mail immediately. */ if (mbox_sync(mbox, 0) < 0) return -1;
--- a/src/lib-storage/index/mbox/mbox-sync-private.h Sun Oct 21 03:09:33 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync-private.h Sun Oct 21 03:33:21 2007 +0300 @@ -147,6 +147,8 @@ int mbox_sync(struct mbox_mailbox *mbox, enum mbox_sync_flags flags); int mbox_sync_has_changed(struct mbox_mailbox *mbox, bool leave_dirty); +int mbox_sync_has_changed_full(struct mbox_mailbox *mbox, bool leave_dirty, + bool *empty_r); void mbox_sync_set_critical(struct mbox_sync_context *sync_ctx, const char *fmt, ...) ATTR_FORMAT(2, 3);
--- a/src/lib-storage/index/mbox/mbox-sync.c Sun Oct 21 03:09:33 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-sync.c Sun Oct 21 03:33:21 2007 +0300 @@ -1483,6 +1483,14 @@ int mbox_sync_has_changed(struct mbox_mailbox *mbox, bool leave_dirty) { + bool empty; + + return mbox_sync_has_changed_full(mbox, leave_dirty, &empty); +} + +int mbox_sync_has_changed_full(struct mbox_mailbox *mbox, bool leave_dirty, + bool *empty_r) +{ const struct mail_index_header *hdr; const struct stat *st; struct stat statbuf; @@ -1501,6 +1509,7 @@ } st = &statbuf; } + *empty_r = st->st_size == 0; hdr = mail_index_get_header(mbox->ibox.view);