]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Don't complain about transaction log indexid changes when rebuilding index.
authorTimo Sirainen <tss@iki.fi>
Fri, 28 May 2004 01:04:01 +0000 (04:04 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 28 May 2004 01:04:01 +0000 (04:04 +0300)
--HG--
branch : HEAD

src/lib-index/mail-index-private.h
src/lib-index/mail-index.c
src/lib-index/mail-transaction-log.c

index b9b55cfe206f644f4fa677ccc81495a6c86cc142..36bd22241ae2a2db8f8b0525534734fda7096a8a 100644 (file)
@@ -73,7 +73,6 @@ struct mail_index {
        unsigned int fsck:1;
 };
 
-void mail_index_header_init(struct mail_index_header *hdr);
 int mail_index_write_header(struct mail_index *index,
                            const struct mail_index_header *hdr);
 
index 1928f603aa89fb550977a499da4ede0fa540e2a6..621b73207fd5729cc776da98a37da0ca1e818fd8 100644 (file)
@@ -425,28 +425,6 @@ mail_index_try_open(struct mail_index *index, unsigned int *lock_id_r)
        return ret;
 }
 
-void mail_index_header_init(struct mail_index_header *hdr)
-{
-       time_t now = time(NULL);
-
-       memset(hdr, 0, sizeof(*hdr));
-
-       hdr->major_version = MAIL_INDEX_MAJOR_VERSION;
-       hdr->minor_version = MAIL_INDEX_MINOR_VERSION;
-       hdr->header_size = sizeof(*hdr);
-
-#ifndef WORDS_BIGENDIAN
-       hdr->compat_data[0] = MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
-#endif
-       hdr->compat_data[1] = sizeof(uoff_t);
-       hdr->compat_data[2] = sizeof(time_t);
-       hdr->compat_data[3] = sizeof(keywords_mask_t);
-
-       hdr->indexid = now;
-
-       hdr->next_uid = 1;
-}
-
 int mail_index_write_header(struct mail_index *index,
                            const struct mail_index_header *hdr)
 {
@@ -545,6 +523,28 @@ static int mail_index_create(struct mail_index *index,
        return 1;
 }
 
+static void mail_index_header_init(struct mail_index_header *hdr)
+{
+       time_t now = time(NULL);
+
+       memset(hdr, 0, sizeof(*hdr));
+
+       hdr->major_version = MAIL_INDEX_MAJOR_VERSION;
+       hdr->minor_version = MAIL_INDEX_MINOR_VERSION;
+       hdr->header_size = sizeof(*hdr);
+
+#ifndef WORDS_BIGENDIAN
+       hdr->compat_data[0] = MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
+#endif
+       hdr->compat_data[1] = sizeof(uoff_t);
+       hdr->compat_data[2] = sizeof(time_t);
+       hdr->compat_data[3] = sizeof(keywords_mask_t);
+
+       hdr->indexid = now;
+
+       hdr->next_uid = 1;
+}
+
 static int mail_index_open_files(struct mail_index *index,
                                 enum mail_index_open_flags flags)
 {
index b2e9abe4aba276944947bb846c9a46026cc6f57c..8fb059a85fce875595f3cf0c00bfe937a4315a5a 100644 (file)
@@ -307,12 +307,13 @@ mail_transaction_log_file_read_hdr(struct mail_transaction_log_file *file,
                        file->filepath);
                return 0;
        }
-       if (file->hdr.indexid != file->log->index->indexid &&
-           file->log->index->indexid != 0) {
-               /* either index was just recreated, or transaction has wrong
-                  indexid. we don't know here which one is the case, so we'll
-                  just fail. If index->indexid == 0, we're rebuilding it and
-                  we just want to lock the transaction log. */
+       if (file->hdr.indexid != file->log->index->indexid) {
+               if (file->log->index->fd == -1) {
+                       /* creating index file, silently rebuild
+                          transaction log as well */
+                       return 0;
+               }
+
                mail_index_set_error(file->log->index,
                        "Transaction log file %s: invalid indexid (%u != %u)",
                        file->filepath, file->hdr.indexid,