[dovecot-cvs] dovecot/src/lib-storage/index index-mail.c, 1.108, 1.109

cras at dovecot.org cras at dovecot.org
Sun Sep 17 20:49:06 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv2225/lib-storage/index

Modified Files:
	index-mail.c 
Log Message:
mail_set_uid() now returns 0 = expunged, 1 = ok.



Index: index-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- index-mail.c	16 Sep 2006 13:40:18 -0000	1.108
+++ index-mail.c	17 Sep 2006 17:49:04 -0000	1.109
@@ -826,7 +826,7 @@
 	const struct mail_index_header *hdr;
 	pool_t pool;
 
-	pool = pool_alloconly_create("mail", 512);
+	pool = pool_alloconly_create("mail", 1024);
 	mail = p_new(pool, struct index_mail, 1);
 	mail->mail.pool = pool;
 	array_create(&mail->mail.module_contexts, pool, sizeof(void *), 5);
@@ -857,6 +857,22 @@
 		i_stream_destroy(&mail->data.filter_stream);
 }
 
+static void index_mail_reset(struct index_mail *mail)
+{
+	struct index_mail_data *data = &mail->data;
+
+	index_mail_close(mail);
+
+	memset(data, 0, sizeof(*data));
+	p_clear(mail->data_pool);
+
+	data->virtual_size = (uoff_t)-1;
+	data->physical_size = (uoff_t)-1;
+	data->save_date = (time_t)-1;
+	data->received_date = (time_t)-1;
+	data->sent_date.time = (time_t)-1;
+}
+
 static void check_envelope(struct index_mail *mail)
 {
 	unsigned int cache_field_envelope =
@@ -903,18 +919,10 @@
 		return -1;
 	}
 
-	index_mail_close(mail);
-
-	memset(data, 0, sizeof(*data));
-	p_clear(mail->data_pool);
+	index_mail_reset(mail);
 
 	data->rec = rec;
 	data->seq = seq;
-	data->virtual_size = (uoff_t)-1;
-	data->physical_size = (uoff_t)-1;
-	data->save_date = (time_t)-1;
-	data->received_date = (time_t)-1;
-	data->sent_date.time = (time_t)-1;
 
 	if (!index_mail_get_fixed_field(mail, MAIL_CACHE_FLAGS,
 					&data->cache_flags,
@@ -1019,7 +1027,16 @@
 					uid, uid, &seq, &seq) < 0)
 		return -1;
 
-	return index_mail_set_seq(_mail, seq);
+	if (seq == 0) {
+		index_mail_reset(mail);
+		mail->mail.mail.uid = uid;
+		mail->mail.mail.expunged = TRUE;
+		return 0;
+	}
+
+	if (index_mail_set_seq(_mail, seq) < 0)
+		return -1;
+	return 1;
 }
 
 void index_mail_free(struct mail *_mail)



More information about the dovecot-cvs mailing list