From 8af21c5604cedc69e5a2fbe23bfbd8e087a674e1 Mon Sep 17 00:00:00 2001 From: Michael Elkins Date: Mon, 18 Jun 2001 21:38:44 +0000 Subject: [PATCH] handle untagged responses in imap_fetch_message() so that it doesn't bomb out if new mail arrives while in the process of downloading noted in BUGS section of man page that if new mail arrives after the initial message list has been retrieved from the IMAP server, that new mail will not be fetched until the next invocation of isync. --- TODO | 3 +++ configure.in | 2 +- imap.c | 20 +++++++++++++++++++- isync.1 | 7 +++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 9fc1131..5987c2d 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,6 @@ add support for syncing with other: and shared: via NAMESPACE finish implementing --quiet + +isync gets confused when new mail is delivered while in the middle of an +IMAP session. need to handled those asynchronous notifications properly. diff --git a/configure.in b/configure.in index 6c75549..6d05ede 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ AC_INIT(isync.h) -AM_INIT_AUTOMAKE(isync,0.5) +AM_INIT_AUTOMAKE(isync,0.6) AM_PROG_CC_STDC if test $CC = gcc; then CFLAGS="$CFLAGS -pipe" diff --git a/imap.c b/imap.c index cc92283..0e8f0d6 100644 --- a/imap.c +++ b/imap.c @@ -421,7 +421,10 @@ imap_exec (imap_t * imap, const char *fmt, ...) snprintf (buf, sizeof (buf), "%d %s\r\n", ++Tag, tmp); if (Verbose) + { + fputs (">>> ", stdout); fputs (buf, stdout); + } n = socket_write (imap->sock, buf, strlen (buf)); if (n <= 0) { @@ -880,7 +883,22 @@ imap_fetch_message (imap_t * imap, unsigned int uid, int fd) next_arg (&cmd); /* * */ next_arg (&cmd); /* */ - next_arg (&cmd); /* FETCH */ + arg = next_arg (&cmd); /* FETCH */ + + if (strcasecmp ("FETCH", arg) != 0) + { + /* this is likely an untagged response, such as when new + * mail arrives in the middle of the session. just skip + * it for now. + * + * eg., + * "* 4000 EXISTS" + * "* 2 RECENT" + * + */ + printf ("skipping untagged response: %s\n", arg); + continue; + } while ((arg = next_arg (&cmd)) && *arg != '{') ; diff --git a/isync.1 b/isync.1 index 8715f62..cfff57d 100644 --- a/isync.1 +++ b/isync.1 @@ -282,6 +282,13 @@ mailbox rather than the :info field. When synchronizing multiple mailboxes on the same IMAP server, it is not possible to select different SSL options for each mailbox. Only the options from the first mailbox are applied since the SSL session is reused. +.P +If new mail arrives in the IMAP mailbox after +.B isync +has retrieved the initial message list, the new mail will not be fetched +until the next time +.B isync +is invoked. .SH SEE ALSO mutt(1), maildir(5) .P