[dovecot-cvs]
dovecot/src/imap cmd-fetch.c, 1.26, 1.27 imap-fetch.c,
1.36, 1.37 imap-fetch.h, 1.13, 1.14
cras at dovecot.org
cras at dovecot.org
Fri Feb 11 20:15:02 EET 2005
Update of /var/lib/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv14773
Modified Files:
cmd-fetch.c imap-fetch.c imap-fetch.h
Log Message:
If UID FETCH notices in the middle of fetching that message is expunged,
don't fail but just don't return all the data.
Index: cmd-fetch.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/cmd-fetch.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cmd-fetch.c 5 Feb 2005 18:07:26 -0000 1.26
+++ cmd-fetch.c 11 Feb 2005 18:14:59 -0000 1.27
@@ -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);
}
Index: imap-fetch.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/imap-fetch.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- imap-fetch.c 5 Feb 2005 18:07:26 -0000 1.36
+++ imap-fetch.c 11 Feb 2005 18:14:59 -0000 1.37
@@ -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;
Index: imap-fetch.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/imap-fetch.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- imap-fetch.h 5 Feb 2005 18:07:26 -0000 1.13
+++ imap-fetch.h 11 Feb 2005 18:14:59 -0000 1.14
@@ -53,6 +53,7 @@
unsigned int cur_append_eoh:1;
unsigned int first:1;
unsigned int line_finished:1;
+ unsigned int partial_fetch:1;
unsigned int failed:1;
};
More information about the dovecot-cvs
mailing list