Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3156:13dbff915a1a HEAD
If UID FETCH notices in the middle of fetching that message is expunged,
don't fail but just don't return all the data.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 11 Feb 2005 20:14:59 +0200 |
parents | 9abab33f1262 |
children | 7eb1995f5a27 |
files | src/imap/cmd-fetch.c src/imap/imap-fetch.c src/imap/imap-fetch.h |
diffstat | 3 files changed, 42 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/cmd-fetch.c Thu Feb 10 00:28:19 2005 +0200 +++ b/src/imap/cmd-fetch.c Fri Feb 11 20:14:59 2005 +0200 @@ -68,26 +68,33 @@ return TRUE; } -static int cmd_fetch_finish(struct client_command_context *cmd, int failed) +static int cmd_fetch_finish(struct imap_fetch_context *ctx) { - struct client *client = cmd->client; + struct client_command_context *cmd = ctx->cmd; static const char *ok_message = "OK Fetch completed."; + int failed, partial; - if (failed) { + partial = ctx->partial_fetch; + failed = ctx->failed; + + if (imap_fetch_deinit(ctx) < 0) + failed = TRUE; + + if (failed || (partial && !cmd->uid)) { struct mail_storage *storage; const char *error; int syntax; - storage = mailbox_get_storage(client->mailbox); + storage = mailbox_get_storage(cmd->client->mailbox); error = mail_storage_get_last_error(storage, &syntax); if (!syntax) { /* We never want to reply NO to FETCH requests, BYE is preferrable (see imap-ml for reasons). */ - if (error == NULL) { + if (partial) { error = "Out of sync: " "Trying to fetch expunged message"; } - client_disconnect_with_error(client, error); + client_disconnect_with_error(cmd->client, error); } else { /* user error, we'll reply with BAD */ client_send_storage_error(cmd, storage); @@ -121,9 +128,7 @@ if (ret < 0) ctx->failed = TRUE; - if (imap_fetch_deinit(ctx) < 0) - ret = -1; - return cmd_fetch_finish(cmd, ret < 0); + return cmd_fetch_finish(ctx); } int cmd_fetch(struct client_command_context *cmd) @@ -171,7 +176,6 @@ } if (ret < 0) ctx->failed = TRUE; - if (imap_fetch_deinit(ctx) < 0) - ret = -1; - return cmd_fetch_finish(cmd, ret < 0); + + return cmd_fetch_finish(ctx); }
--- a/src/imap/imap-fetch.c Thu Feb 10 00:28:19 2005 +0200 +++ b/src/imap/imap-fetch.c Fri Feb 11 20:14:59 2005 +0200 @@ -163,8 +163,19 @@ int ret; if (ctx->cont_handler != NULL) { - if ((ret = ctx->cont_handler(ctx)) <= 0) - return ret; + ret = ctx->cont_handler(ctx); + if (ret == 0) + return 0; + + if (ret < 0) { + if (ctx->cur_mail->expunged) { + /* not an error, just lost it. */ + ctx->partial_fetch = TRUE; + ctx->partial_fetch = TRUE; + } else { + return -1; + } + } ctx->cont_handler = NULL; ctx->cur_offset = 0; @@ -212,9 +223,18 @@ handlers[ctx->cur_handler].context); t_pop(); - if (ret <= 0) { - i_assert(ret < 0 || ctx->cont_handler != NULL); - return ret; + if (ret == 0) + return 0; + + if (ret < 0) { + if (ctx->cur_mail->expunged) { + /* not an error, just lost it. */ + ctx->partial_fetch = TRUE; + } else { + i_assert(ret < 0 || + ctx->cont_handler != NULL); + return -1; + } } ctx->cont_handler = NULL;