changeset 261:29cf23950452 HEAD

Report FETCH failure properly
author Timo Sirainen <tss@iki.fi>
date Mon, 16 Sep 2002 15:59:06 +0300
parents 38282593753f
children f5b444bf9157
files src/lib-storage/index/index-fetch.c src/lib-storage/index/index-fetch.h src/lib-storage/index/index-messageset.h
diffstat 3 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-fetch.c	Mon Sep 16 15:28:59 2002 +0300
+++ b/src/lib-storage/index/index-fetch.c	Mon Sep 16 15:59:06 2002 +0300
@@ -23,7 +23,8 @@
 		t_string_printfa(ctx->str, "BODY %s ", body);
 		return TRUE;
 	} else {
-		i_error("Couldn't generate BODY for UID %u (index %s)",
+		mail_storage_set_critical(ctx->storage,
+			"Couldn't generate BODY for UID %u (index %s)",
 			rec->uid, ctx->index->filepath);
 		return FALSE;
 	}
@@ -39,7 +40,8 @@
 				 bodystructure);
 		return TRUE;
 	} else {
-		i_error("Couldn't generate BODYSTRUCTURE for UID %u (index %s)",
+		mail_storage_set_critical(ctx->storage,
+			"Couldn't generate BODYSTRUCTURE for UID %u (index %s)",
 			rec->uid, ctx->index->filepath);
 		return FALSE;
 	}
@@ -54,7 +56,8 @@
 		t_string_printfa(ctx->str, "ENVELOPE (%s) ", envelope);
 		return TRUE;
 	} else {
-		i_error("Couldn't generate ENVELOPE for UID %u (index %s)",
+		mail_storage_set_critical(ctx->storage,
+			"Couldn't generate ENVELOPE for UID %u (index %s)",
 			rec->uid, ctx->index->filepath);
 		return FALSE;
 	}
@@ -66,7 +69,8 @@
 
 	if (!imap_msgcache_get_rfc822(ctx->cache, NULL,
 				      &hdr_size, &body_size)) {
-		i_error("Couldn't get RFC822.SIZE for UID %u (index %s)",
+		mail_storage_set_critical(ctx->storage,
+			"Couldn't get RFC822.SIZE for UID %u (index %s)",
 			rec->uid, ctx->index->filepath);
 		return FALSE;
 	}
@@ -109,7 +113,8 @@
 
 	if (!imap_msgcache_get_rfc822(ctx->cache, &inbuf,
 				      &hdr_size, &body_size)) {
-		i_error("Couldn't get RFC822 for UID %u (index %s)",
+		mail_storage_set_critical(ctx->storage,
+			"Couldn't get RFC822 for UID %u (index %s)",
 			rec->uid, ctx->index->filepath);
 		return FALSE;
 	}
@@ -135,7 +140,8 @@
 	const char *str;
 
 	if (!imap_msgcache_get_rfc822(ctx->cache, &inbuf, &hdr_size, NULL)) {
-		i_error("Couldn't get RFC822.HEADER for UID %u (index %s)",
+		mail_storage_set_critical(ctx->storage,
+			"Couldn't get RFC822.HEADER for UID %u (index %s)",
 			rec->uid, ctx->index->filepath);
 		return FALSE;
 	}
@@ -158,7 +164,8 @@
 	const char *str;
 
 	if (!imap_msgcache_get_rfc822(ctx->cache, &inbuf, NULL, &body_size)) {
-		i_error("Couldn't get RFC822.TEXT for UID %u (index %s)",
+		mail_storage_set_critical(ctx->storage,
+			"Couldn't get RFC822.TEXT for UID %u (index %s)",
 			rec->uid, ctx->index->filepath);
 		return FALSE;
 	}
@@ -334,6 +341,7 @@
 
 	memset(&ctx, 0, sizeof(ctx));
 	ctx.box = box;
+	ctx.storage = box->storage;
 	ctx.cache = ibox->cache;
 	ctx.index = ibox->index;
 	ctx.custom_flags =
@@ -375,5 +383,5 @@
 			return FALSE;
 	}
 
-	return ret >= 0;
+	return ret > 0;
 }
--- a/src/lib-storage/index/index-fetch.h	Mon Sep 16 15:28:59 2002 +0300
+++ b/src/lib-storage/index/index-fetch.h	Mon Sep 16 15:59:06 2002 +0300
@@ -3,6 +3,7 @@
 
 typedef struct {
 	Mailbox *box;
+	MailStorage *storage;
 	ImapMessageCache *cache;
 	MailIndex *index;
 	const char **custom_flags;
--- a/src/lib-storage/index/index-messageset.h	Mon Sep 16 15:28:59 2002 +0300
+++ b/src/lib-storage/index/index-messageset.h	Mon Sep 16 15:59:06 2002 +0300
@@ -7,6 +7,9 @@
 typedef int (*MsgsetForeachFunc)(MailIndex *index, MailIndexRecord *rec,
 				 unsigned int seq, void *context);
 
+/* Returns 1 if all were found, 2 if some messages were deleted,
+   0 func returned FALSE, -1 if internal error occured or -2 if messageset
+   was invalid. */
 int index_messageset_foreach(IndexMailbox *ibox,
 			     const char *messageset, int uidset,
 			     MsgsetForeachFunc func, void *context);