diff src/lib-index/mail-index.c @ 5820:e59892590a02 HEAD

Handle losing index file better. Handle fsck better.
author Timo Sirainen <tss@iki.fi>
date Thu, 28 Jun 2007 01:48:59 +0300
parents 4ea31bf18a56
children f17d4bccd74d
line wrap: on
line diff
--- a/src/lib-index/mail-index.c	Thu Jun 28 01:03:18 2007 +0300
+++ b/src/lib-index/mail-index.c	Thu Jun 28 01:48:59 2007 +0300
@@ -364,9 +364,11 @@
 
 	if (ret == 0) {
 		/* it's corrupted - recreate it */
-		if (close(index->fd) < 0)
-			mail_index_set_syscall_error(index, "close()");
-		index->fd = -1;
+		if (index->fd != -1) {
+			if (close(index->fd) < 0)
+				mail_index_set_syscall_error(index, "close()");
+			index->fd = -1;
+		}
 	}
 	return ret;
 }
@@ -618,11 +620,6 @@
 	return -1;
 }
 
-void mail_index_set_inconsistent(struct mail_index *index)
-{
-	index->indexid = 0;
-}
-
 int mail_index_move_to_memory(struct mail_index *index)
 {
 	struct mail_index_map *map;
@@ -667,7 +664,7 @@
 
 void mail_index_mark_corrupted(struct mail_index *index)
 {
-	mail_index_set_inconsistent(index);
+	index->indexid = 0;
 
 	index->map->hdr.flags |= MAIL_INDEX_HDR_FLAG_CORRUPTED;
 	if (unlink(index->filepath) < 0 && errno != ENOENT && errno != ESTALE)