dovecot-1.0: If header counts are invalid, fix them instead of f...

dovecot at dovecot.org dovecot at dovecot.org
Fri Nov 16 20:08:10 EET 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/96e896e1cf2e
changeset: 5457:96e896e1cf2e
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Nov 16 20:08:07 2007 +0200
description:
If header counts are invalid, fix them instead of failing completely.

diffstat:

1 file changed, 16 insertions(+), 8 deletions(-)
src/lib-index/mail-index-sync-update.c |   24 ++++++++++++++++--------

diffs (55 lines):

diff -r 68e09f7bb619 -r 96e896e1cf2e src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c	Fri Nov 16 19:56:10 2007 +0200
+++ b/src/lib-index/mail-index-sync-update.c	Fri Nov 16 20:08:07 2007 +0200
@@ -231,6 +231,16 @@ mail_index_header_update_lowwaters(struc
 		hdr->first_deleted_uid_lowwater = rec->uid;
 }
 
+static void
+mail_index_sync_header_fix_counts(struct mail_index_sync_map_ctx *ctx,
+				  const char *error)
+{
+	mail_index_set_error(ctx->view->index,
+			     "Fixing header counts in index %s: %s",
+			     ctx->view->index->filepath, error);
+	mail_index_view_recalc_counters(ctx->view);
+}
+
 static int sync_expunge(const struct mail_transaction_expunge *e,
 			struct mail_index_sync_map_ctx *ctx)
 {
@@ -292,8 +302,8 @@ static int sync_expunge(const struct mai
 			if (mail_index_header_update_counts(&map->hdr,
 							    rec->flags, 0,
 							    &error) < 0) {
-				mail_index_sync_set_corrupted(ctx, "%s", error);
-				return -1;
+				mail_index_sync_header_fix_counts(ctx, error);
+				break;
 			}
 		}
 	}
@@ -380,10 +390,8 @@ static int sync_append(const struct mail
 	mail_index_header_update_lowwaters(&map->hdr, rec);
 	if (!view->broken_counters) {
 		if (mail_index_header_update_counts(&map->hdr, 0, rec->flags,
-						    &error) < 0) {
-			mail_index_sync_set_corrupted(ctx, "%s", error);
-			return -1;
-		}
+						    &error) < 0)
+			mail_index_sync_header_fix_counts(ctx, error);
 	}
 	return 1;
 }
@@ -446,8 +454,8 @@ static int sync_flag_update(const struct
 			if (mail_index_header_update_counts(hdr, old_flags,
 							    rec->flags,
 							    &error) < 0) {
-				mail_index_sync_set_corrupted(ctx, "%s", error);
-				return -1;
+				mail_index_sync_header_fix_counts(ctx, error);
+				break;
 			}
 		}
 	}


More information about the dovecot-cvs mailing list