isync

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

commit b570c17766a2ef1c12cf6e6653a878a3f93a65ee
parent 17c4748dfa347389099844ae48c7cb51dbac026c
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Wed, 25 Sep 2013 17:13:00 +0200

deal with messages disappearing between being listed and fetched

Diffstat:
Msrc/drv_imap.c | 17++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/drv_imap.c b/src/drv_imap.c @@ -1876,6 +1876,8 @@ imap_submit_load( imap_store_t *ctx, const char *buf, int tuids, struct imap_cmd /******************* imap_fetch_msg *******************/ +static void imap_fetch_msg_p2( imap_store_t *ctx, struct imap_cmd *gcmd, int response ); + static void imap_fetch_msg( store_t *ctx, message_t *msg, msg_data_t *data, void (*cb)( int sts, void *aux ), void *aux ) @@ -1885,12 +1887,25 @@ imap_fetch_msg( store_t *ctx, message_t *msg, msg_data_t *data, INIT_IMAP_CMD_X(imap_cmd_fetch_msg, cmd, cb, aux) cmd->gen.gen.param.uid = msg->uid; cmd->msg_data = data; - imap_exec( (imap_store_t *)ctx, &cmd->gen.gen, imap_done_simple_msg, + data->data = 0; + imap_exec( (imap_store_t *)ctx, &cmd->gen.gen, imap_fetch_msg_p2, "UID FETCH %d (%s%sBODY.PEEK[])", msg->uid, !(msg->status & M_FLAGS) ? "FLAGS " : "", (data->date== -1) ? "INTERNALDATE " : "" ); } +static void +imap_fetch_msg_p2( imap_store_t *ctx, struct imap_cmd *gcmd, int response ) +{ + struct imap_cmd_fetch_msg *cmd = (struct imap_cmd_fetch_msg *)gcmd; + + if (response == RESP_OK && !cmd->msg_data->data) { + /* The FETCH succeeded, but there is no message with this UID. */ + response = RESP_NO; + } + imap_done_simple_msg( ctx, gcmd, response ); +} + /******************* imap_set_flags *******************/ static void imap_set_flags_p2( imap_store_t *, struct imap_cmd *, int );