From 95a22739fa16435d5d709c5a3bfc8e466ee8d1d2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 29 Dec 2021 14:42:22 +0100 Subject: [PATCH] don't UID EXPUNGE too many messages we didn't check that the UIDs are adjacent, so we might have caught not fetched deleted messages between two fetched messages below the bulk load range. checking adjacency of UIDs would make expunges in the bulk range (which is likely to be full of holes) rather inefficient. so we use sequence numbers instead. this is admittedly a rather academical fix ... amends 18225344. --- src/drv_imap.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index b58828c..55192ff 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -3128,7 +3128,18 @@ imap_close_box( store_t *gctx, buf[bl++] = ','; bl += sprintf( buf + bl, "%u", msg->uid ); fmsg = msg; - for (; (nmsg = msg->next) && (nmsg->flags & F_DELETED); msg = nmsg) {} + for (; (nmsg = msg->next); msg = nmsg) { + if (nmsg->status & M_DEAD) { + // Messages that jump a gap interrupt the range, even expunged ones. + if (nmsg->seq) + break; + } else { + if (nmsg->seq > 1) + break; + if (!(nmsg->flags & F_DELETED)) + break; + } + } if (msg != fmsg) bl += sprintf( buf + bl, ":%u", msg->uid ); }