changeset 4038:6d80874fd704 HEAD

Update message_count only after expunge sends are finished or we'll get to infinite loop (broken in last commit).
author Timo Sirainen <tss@iki.fi>
date Mon, 20 Feb 2006 19:34:02 +0200
parents 3531cc5270b5
children fcd4c3281559
files src/imap/imap-sync.c
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-sync.c	Mon Feb 20 19:17:15 2006 +0200
+++ b/src/imap/imap-sync.c	Mon Feb 20 19:34:02 2006 +0200
@@ -154,12 +154,8 @@
 			}
 			break;
 		case MAILBOX_SYNC_TYPE_EXPUNGE:
-			if (ctx->seq == 0) {
+			if (ctx->seq == 0)
 				ctx->seq = ctx->sync_rec.seq2;
-				ctx->messages_count -=
-					ctx->sync_rec.seq2 -
-					ctx->sync_rec.seq1 + 1;
-			}
 			ret = 1;
 			for (; ctx->seq >= ctx->sync_rec.seq1; ctx->seq--) {
 				if (ret <= 0)
@@ -169,6 +165,14 @@
 				str_printfa(str, "* %u EXPUNGE", ctx->seq);
 				ret = client_send_line(ctx->client, str_c(str));
 			}
+			if (ctx->seq < ctx->sync_rec.seq1) {
+				/* update only after we're finished, so that
+				   the seq2 > messages_count check above
+				   doesn't break */
+				ctx->messages_count -=
+					ctx->sync_rec.seq2 -
+					ctx->sync_rec.seq1 + 1;
+			}
 			break;
 		}
 		if (ret <= 0) {