From c260a67eb2a4a93567a7a975b6ebe92204fc9b49 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 1 Feb 2002 02:14:24 +0000 Subject: Before the next fix round. svn path=/trunk/; revision=3569 --- imap.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'imap.c') diff --git a/imap.c b/imap.c index 9a22a37c..9043a9ad 100644 --- a/imap.c +++ b/imap.c @@ -29,8 +29,9 @@ extern char *strstr(); /* needed on sysV68 R3V7.1. */ #define IMAP4 0 /* IMAP4 rev 0, RFC1730 */ #define IMAP4rev1 1 /* IMAP4 rev 1, RFC2060 */ -static int count, unseen, deletions, imap_version, preauth; -static int expunged, expunge_period, saved_timeout; +static int count, unseen, deletions = 0; +static int expunged, expunge_period, saved_timeout = 0; +static int imap_version, preauth; static flag do_idle; static char capabilities[MSGBUFSIZE+1]; static unsigned int *unseen_messages; @@ -519,6 +520,23 @@ static int imap_getrange(int sock, /* no messages? then we may need to idle until we get some */ if (count == 0 && do_idle) imap_idle(sock); + + /* + * We should have an expunge here to + * a) avoid fetching deleted mails during 'fetchall' + * b) getting a wrong count of mails during 'no fetchall' + */ + if (!check_only && !ctl->keep && count > 0) + { + ok = internal_expunge(sock); + if (ok) + { + report(stderr, GT_("expunge failed\n")); + return(ok); + } + if (outlevel >= O_DEBUG) + report(stdout, GT_("%d messages waiting after expunge\n"), count); + } } *countp = count; @@ -576,6 +594,7 @@ static int imap_getrange(int sock, *newp = unseen; expunged = 0; + deletions = 0; return(PS_SUCCESS); } -- cgit v1.2.3