# HG changeset patch # User Timo Sirainen # Date 1030809727 -10800 # Node ID 08186ac2784e2df3b6c74ec3912ec8651ee4ced2 # Parent fc3383ac21a92e6a55950c6455b2de046e1adda0 Fixed some index rebuilding behaviour. diff -r fc3383ac21a9 -r 08186ac2784e src/lib-index/mail-hash.c --- 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; diff -r fc3383ac21a9 -r 08186ac2784e src/lib-index/mail-index-data.c --- 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; } diff -r fc3383ac21a9 -r 08186ac2784e src/lib-index/mail-index.c --- 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)