Skip to content

Commit

Permalink
lib-index: mail_transaction_log_view_set_all() - don't entirely ignor…
Browse files Browse the repository at this point in the history
…e corrupted logs

Ignore them only if it's followed by an index reset.
  • Loading branch information
sirainen authored and villesavolainen committed May 22, 2017
1 parent 65e20e8 commit f71db30
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/lib-index/mail-transaction-log-view.c
Expand Up @@ -349,6 +349,7 @@ int mail_transaction_log_view_set_all(struct mail_transaction_log_view *view)
{
struct mail_transaction_log_file *file, *first;
const char *reason;
int ret;

/* make sure .log.2 file is opened */
(void)mail_transaction_log_find_file(view->log, 1, FALSE, &file, &reason);
Expand All @@ -357,14 +358,22 @@ int mail_transaction_log_view_set_all(struct mail_transaction_log_view *view)
i_assert(first != NULL);

for (file = view->log->files; file != NULL; file = file->next) {
if (mail_transaction_log_file_map(file, file->hdr.hdr_size,
(uoff_t)-1) < 0)
ret = mail_transaction_log_file_map(file, file->hdr.hdr_size,
(uoff_t)-1);
if (ret < 0)
return -1;
if (file->hdr.prev_file_seq == 0) {
if (ret == 0) {
/* corrupted */
first = NULL;
} else if (file->hdr.prev_file_seq == 0) {
/* this file resets the index. skip the old ones. */
first = file;
}
}
if (first == NULL) {
/* index wasn't reset after corruption was found */
return -1;
}

mail_transaction_log_view_unref_all(view);
for (file = first; file != NULL; file = file->next) {
Expand Down

0 comments on commit f71db30

Please sign in to comment.