Mercurial > dovecot > original-hg > dovecot-1.2
changeset 103:08186ac2784e HEAD
Fixed some index rebuilding behaviour.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 31 Aug 2002 19:02:07 +0300 |
parents | fc3383ac21a9 |
children | a6d7ed739926 |
files | src/lib-index/mail-hash.c src/lib-index/mail-index-data.c src/lib-index/mail-index.c |
diffstat | 3 files changed, 27 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-hash.c Sat Aug 31 18:45:55 2002 +0300 +++ b/src/lib-index/mail-hash.c Sat Aug 31 19:02:07 2002 +0300 @@ -147,6 +147,7 @@ int mail_hash_open_or_create(MailIndex *index) { MailHash *hash; + int failed; hash = mail_hash_new(index); @@ -161,9 +162,19 @@ } /* make sure the header looks fine */ - if (!hash_verify_header(hash) || - hash->header->indexid != hash->index->indexid) { - /* just recreate it */ + failed = TRUE; + if (hash_verify_header(hash)) { + if (hash->header->indexid == hash->index->indexid) + failed = FALSE; + else { + index_set_error(hash->index, + "IndexID mismatch for hash file %s", + hash->filepath); + } + } + + if (failed) { + /* recreate it */ (void)munmap(hash->mmap_base, hash->mmap_length); hash->mmap_base = NULL; hash->dirty_mmap = TRUE;
--- a/src/lib-index/mail-index-data.c Sat Aug 31 18:45:55 2002 +0300 +++ b/src/lib-index/mail-index-data.c Sat Aug 31 19:02:07 2002 +0300 @@ -92,7 +92,8 @@ hdr = data->mmap_base; if (hdr->indexid != index->indexid) { INDEX_MARK_CORRUPTED(index); - index_set_error(index, "IndexID mismatch with file %s", path); + index_set_error(index, "IndexID mismatch for data file %s", + path); mail_index_data_free(data); return FALSE; }
--- a/src/lib-index/mail-index.c Sat Aug 31 18:45:55 2002 +0300 +++ b/src/lib-index/mail-index.c Sat Aug 31 19:02:07 2002 +0300 @@ -537,17 +537,18 @@ if (!mail_index_data_create(index)) break; } + + if (hdr.flags & MAIL_INDEX_FLAG_REBUILD) { + /* index is corrupted, rebuild */ + if (!index->rebuild(index)) + break; + } + if (!mail_hash_open_or_create(index)) break; if (!mail_modifylog_open_or_create(index)) break; - if (hdr.flags & MAIL_INDEX_FLAG_REBUILD) { - /* index is corrupted, rebuild */ - if (!mail_index_rebuild_all(index)) - break; - } - if (hdr.flags & MAIL_INDEX_FLAG_FSCK) { /* index needs fscking */ if (!index->fsck(index)) @@ -1167,7 +1168,7 @@ i_assert(index->lock_type == MAIL_LOCK_EXCLUSIVE); i_assert(rec->uid != 0); - if (seq != 0) { + if (seq != 0 && index->modifylog != NULL) { if (!mail_modifylog_add_expunge(index->modifylog, seq, rec->uid, external_change)) return FALSE; @@ -1262,8 +1263,9 @@ index_mark_flag_changes(index, rec, rec->msg_flags, flags); rec->msg_flags = flags; - return mail_modifylog_add_flags(index->modifylog, seq, - rec->uid, external_change); + return index->modifylog == NULL ? TRUE : + mail_modifylog_add_flags(index->modifylog, seq, + rec->uid, external_change); } int mail_index_append(MailIndex *index, MailIndexRecord **rec)