From 4078733e58f156dcf5c472a40eb90ee1026407ff Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 25 Aug 2017 15:12:06 +0300 Subject: [PATCH] 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). --- src/lib-index/mail-transaction-log.c | 7 +++++++ 1 file changed, 7 insertions(+) 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)) { -- 2.47.3