]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Avoid opening .log.2 file if .log was reset
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 25 Aug 2017 12:12:06 +0000 (15:12 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Fri, 25 Aug 2017 12:47:19 +0000 (15:47 +0300)
After a reset there's no point in trying to read the older log files.
This avoids trying to open .log.2 at least for newly created mailboxes
when trying to lookup log file sequence 1 (since due to some bug/feature
the log files start from sequence 2).

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

index 3cf8d5fa0b8d21fed424d108484fb694a322756b..f742f7f9ae18678485670d80c8a76d3eda56b1f5 100644 (file)
@@ -442,6 +442,13 @@ int mail_transaction_log_find_file(struct mail_transaction_log *log,
                        *file_r = file;
                        return 1;
                }
+               if (file->hdr.file_seq > file_seq &&
+                   file->hdr.prev_file_seq == 0) {
+                       /* Fail here mainly to avoid unnecessarily trying to
+                          open .log.2 that most likely doesn't even exist. */
+                       *reason_r = "Log was reset after requested file_seq";
+                       return 0;
+               }
        }
 
        if (MAIL_INDEX_IS_IN_MEMORY(log->index)) {