changeset 6258:63b744cb99a4 HEAD

If received date or physical size fetching fails because mail was expunged, mark the mail expunged instead of failing with unknown error.
author Timo Sirainen <tss@iki.fi>
date Fri, 10 Aug 2007 14:39:00 +0300
parents 2618805b3d94
children f2b00d3996df
files src/lib-storage/index/maildir/maildir-mail.c
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-mail.c	Fri Aug 10 14:30:03 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-mail.c	Fri Aug 10 14:39:00 2007 +0300
@@ -70,7 +70,7 @@
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->box;
 	struct index_mail_data *data = &((struct index_mail *)mail)->data;
 	const char *path;
-	int fd;
+	int fd, ret;
 
 	if (data->access_part != 0 && data->stream == NULL) {
 		/* we're going to open the mail anyway */
@@ -87,8 +87,12 @@
 			return -1;
 		}
 	} else if (mail->uid != 0) {
-		if (maildir_file_do(mbox, mail->uid, do_stat, st) <= 0)
+		ret = maildir_file_do(mbox, mail->uid, do_stat, st);
+		if (ret <= 0) {
+			if (ret == 0)
+				mail_set_expunged(mail);
 			return -1;
+		}
 	} else {
 		path = maildir_save_file_get_path(mail->transaction, mail->seq);
 		if (do_stat(mbox, path, st) <= 0)
@@ -303,6 +307,7 @@
 	struct stat st;
 	const char *path, *fname;
 	uoff_t size;
+	int ret;
 
 	size = index_mail_get_physical_size(_mail);
 	if (size != (uoff_t)-1)
@@ -322,9 +327,12 @@
 	/* size can be included in filename */
 	if (!maildir_filename_get_size(fname, MAILDIR_EXTRA_FILE_SIZE, &size)) {
 		if (_mail->uid != 0) {
-			if (maildir_file_do(mbox, _mail->uid,
-					    do_stat, &st) <= 0)
+			ret = maildir_file_do(mbox, _mail->uid, do_stat, &st);
+			if (ret <= 0) {
+				if (ret == 0)
+					mail_set_expunged(_mail);
 				return (uoff_t)-1;
+			}
 		} else {
 			/* saved mail which hasn't been committed yet */
 			if (do_stat(mbox, path, &st) <= 0)