changeset 2085:258c8ef1bdc4 HEAD

assert fix
author Timo Sirainen <tss@iki.fi>
date Sun, 30 May 2004 07:28:07 +0300
parents 9ba79ebae6ab
children 5c851ff00f1a
files src/lib-index/mail-transaction-log-view.c
diffstat 1 files changed, 18 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log-view.c	Sun May 30 06:57:15 2004 +0300
+++ b/src/lib-index/mail-transaction-log-view.c	Sun May 30 07:28:07 2004 +0300
@@ -88,27 +88,11 @@
 	if (view->log == NULL)
 		return -1;
 
-	ret = mail_transaction_log_file_find(view->log, min_file_seq, &file);
-	if (ret <= 0) {
-		if (ret == 0 &&
-		    min_file_seq == view->log->tail->hdr.prev_file_seq &&
-		    min_file_offset == view->log->tail->hdr.prev_file_offset) {
-			/* we can skip this */
-			min_file_seq = view->log->tail->hdr.file_seq;
-			min_file_offset =
-				sizeof(struct mail_transaction_log_header);
-			ret = mail_transaction_log_file_find(view->log,
-							     min_file_seq,
-							     &file);
-		}
-
-		if (ret == 0) {
-			mail_index_set_error(view->log->index,
-				"Lost transaction log file %s seq %u",
-				view->log->tail->filepath, min_file_seq);
-		}
-		if (ret <= 0)
-			return -1;
+	if (min_file_seq == view->log->tail->hdr.prev_file_seq &&
+	    min_file_offset == view->log->tail->hdr.prev_file_offset) {
+		/* we can skip this */
+		min_file_seq = view->log->tail->hdr.file_seq;
+		min_file_offset = sizeof(struct mail_transaction_log_header);
 
 		if (min_file_seq > max_file_seq) {
 			/* empty view */
@@ -117,6 +101,16 @@
 		}
 	}
 
+	ret = mail_transaction_log_file_find(view->log, min_file_seq, &file);
+	if (ret <= 0) {
+		if (ret == 0) {
+			mail_index_set_error(view->log->index,
+				"Lost transaction log file %s seq %u",
+				view->log->tail->filepath, min_file_seq);
+		}
+		return -1;
+	}
+
 	/* check these later than others as index file may have corrupted
 	   log_file_offset. we should have recreated the log file and
 	   skipped min_file_seq file above.. max_file_offset can be broken
@@ -154,8 +148,9 @@
 			file->refcount--;
 		view->tail = first;
 	} else {
-		/* we shouldn't go backwards in log */
-		i_assert(first == view->tail);
+		/* going backwards, reference them */
+		for (file = first; file != view->tail; file = file->next)
+			file->refcount++;
 	}
 
 	/* reference all new files */