Mercurial > dovecot > core-2.2
changeset 1446:91bb57655d96 HEAD
Don't try to rewrite mbox file if it's read-only.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 08 May 2003 08:08:29 +0300 |
parents | e29bc94711e2 |
children | 0d25b85dbe25 |
files | src/lib-index/mbox/mbox-append.c src/lib-index/mbox/mbox-rewrite.c src/lib-index/mbox/mbox-sync.c |
diffstat | 3 files changed, 17 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mbox/mbox-append.c Thu May 08 07:53:47 2003 +0300 +++ b/src/lib-index/mbox/mbox-append.c Thu May 08 08:08:29 2003 +0300 @@ -93,7 +93,13 @@ if (index->header->messages_count == 0 && ctx.uid_validity != index->header->uid_validity) { /* UID validity is different */ - if (ctx.uid_validity == 0) { + if (ctx.uid_validity != 0) { + /* change it in index */ + index->header->uid_validity = ctx.uid_validity; + index->header->next_uid = 1; + index->header->last_nonrecent_uid = 0; + index->inconsistent = TRUE; + } else if (!index->mailbox_readonly) { /* we have to write it to mbox */ if (index->mbox_lock_type != MAIL_LOCK_EXCLUSIVE) { /* try again */ @@ -103,12 +109,6 @@ MAIL_INDEX_FLAG_DIRTY_MESSAGES; rec->index_flags |= INDEX_MAIL_FLAG_DIRTY; } - } else { - /* change it in index */ - index->header->uid_validity = ctx.uid_validity; - index->header->next_uid = 1; - index->header->last_nonrecent_uid = 0; - index->inconsistent = TRUE; } } @@ -116,7 +116,7 @@ /* X-UID header looks ok */ if (ret != 0) index->header->next_uid = ctx.uid; - dirty = ctx.content_length_broken && !index->mailbox_readonly; + dirty = ctx.content_length_broken; } else if (!index->mailbox_readonly) { /* Write X-UID for it */ dirty = TRUE; @@ -128,7 +128,7 @@ dirty = FALSE; } - if (dirty) { + if (dirty && !index->mailbox_readonly) { if (index->mbox_lock_type != MAIL_LOCK_EXCLUSIVE) { /* try again */ ret = 0;
--- a/src/lib-index/mbox/mbox-rewrite.c Thu May 08 07:53:47 2003 +0300 +++ b/src/lib-index/mbox/mbox-rewrite.c Thu May 08 08:08:29 2003 +0300 @@ -569,6 +569,7 @@ unsigned int seq; int tmp_fd, failed, dirty_found, rewrite, no_locking; + i_assert(!index->mailbox_readonly); i_assert(index->lock_type == MAIL_LOCK_UNLOCK || (index->lock_type == MAIL_LOCK_EXCLUSIVE && index->mbox_lock_type == MAIL_LOCK_EXCLUSIVE));
--- a/src/lib-index/mbox/mbox-sync.c Thu May 08 07:53:47 2003 +0300 +++ b/src/lib-index/mbox/mbox-sync.c Thu May 08 08:08:29 2003 +0300 @@ -75,6 +75,13 @@ i_assert(index->lock_type != MAIL_LOCK_SHARED); + if (index->mailbox_readonly && data_lock_type == MAIL_LOCK_EXCLUSIVE) { + index_set_error(index, "sync: %s is read-only, " + "can't get exclusive lock", + index->mailbox_path); + return FALSE; + } + if (changes != NULL) *changes = FALSE;