From: Timo Sirainen Date: Fri, 25 Aug 2017 12:12:06 +0000 (+0300) Subject: lib-index: Avoid opening .log.2 file if .log was reset X-Git-Tag: 2.3.0.rc1~1140 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4078733e58f156dcf5c472a40eb90ee1026407ff;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Avoid opening .log.2 file if .log was reset 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). --- diff --git a/src/lib-index/mail-transaction-log.c b/src/lib-index/mail-transaction-log.c index 3cf8d5fa0b..f742f7f9ae 100644 --- a/src/lib-index/mail-transaction-log.c +++ b/src/lib-index/mail-transaction-log.c @@ -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)) {