isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 8af21c5604cedc69e5a2fbe23bfbd8e087a674e1
parent 9a5b57eb7dc635568823f693e88cb2b97b456606
Author: Michael Elkins <me@mutt.org>
Date:   Mon, 18 Jun 2001 21:38:44 +0000

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.

Diffstat:
MTODO | 3+++
Mconfigure.in | 2+-
Mimap.c | 20+++++++++++++++++++-
Misync.1 | 7+++++++
4 files changed, 30 insertions(+), 2 deletions(-)

diff --git 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 @@ -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 @@ -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); /* <msgno> */ - 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 @@ -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