From 86d9a3140d315e821b6fdf6752a588e932101969 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 8 Sep 2004 14:52:22 +0000 Subject: [PATCH] first check _both_ bounds, then compare ... --- src/drv_maildir.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/drv_maildir.c b/src/drv_maildir.c index a5a2fd4..e9671ef 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -822,11 +822,28 @@ maildir_rescan( maildir_store_t *ctx ) for (msgapp = &ctx->gen.msgs, i = 0; (msg = (maildir_message_t *)*msgapp) || i < msglist.nents; ) { - if (!msg || msglist.ents[i].uid < msg->gen.uid) { + if (!msg) { +#if 0 + debug( "adding new message %d\n", msglist.ents[i].uid ); + maildir_app_msg( ctx, &msgapp, msglist.ents + i ); +#else debug( "ignoring new message %d\n", msglist.ents[i].uid ); - /* maildir_app_msg( ctx, &msgapp, msglist.ents + i ); */ +#endif i++; - } else if (i >= msglist.nents || msglist.ents[i].uid > msg->gen.uid) { + } else if (i >= msglist.nents) { + debug( "purging deleted message %d\n", msg->gen.uid ); + msg->gen.status = M_DEAD; + msgapp = &msg->gen.next; + } else if (msglist.ents[i].uid < msg->gen.uid) { + /* this should not happen, actually */ +#if 0 + debug( "adding new message %d\n", msglist.ents[i].uid ); + maildir_app_msg( ctx, &msgapp, msglist.ents + i ); +#else + debug( "ignoring new message %d\n", msglist.ents[i].uid ); +#endif + i++; + } else if (msglist.ents[i].uid > msg->gen.uid) { debug( "purging deleted message %d\n", msg->gen.uid ); msg->gen.status = M_DEAD; msgapp = &msg->gen.next;