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.
This commit is contained in:
Michael Elkins 2001-06-18 21:38:44 +00:00
parent 9a5b57eb7d
commit 8af21c5604
4 changed files with 30 additions and 2 deletions

3
TODO
View File

@ -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.

View File

@ -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"

20
imap.c
View File

@ -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 != '{')
;

View File

@ -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