[dovecot-cvs] dovecot/src/plugins/trash trash-plugin.c, 1.5.2.5, 1.5.2.6

tss at dovecot.org tss at dovecot.org
Fri Feb 16 18:31:31 UTC 2007


Update of /var/lib/cvs/dovecot/src/plugins/trash
In directory talvi:/tmp/cvs-serv15748

Modified Files:
      Tag: branch_1_0
	trash-plugin.c 
Log Message:
Although messages were expunged, the expunges weren't counted in that same
transaction and the APPEND failed.



Index: trash-plugin.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/trash/trash-plugin.c,v
retrieving revision 1.5.2.5
retrieving revision 1.5.2.6
diff -u -d -r1.5.2.5 -r1.5.2.6
--- trash-plugin.c	16 Feb 2007 18:01:13 -0000	1.5.2.5
+++ trash-plugin.c	16 Feb 2007 18:31:29 -0000	1.5.2.6
@@ -108,7 +108,7 @@
 	struct trash_mailbox *trashes;
 	unsigned int i, j, count, oldest_idx;
 	time_t oldest, received;
-	uint64_t size;
+	uint64_t size, size_expunged = 0, expunged_count = 0;
 	int ret = 0;
 
 	trashes = array_get_modifyable(&trash_boxes, &count);
@@ -143,17 +143,21 @@
 		}
 
 		if (oldest_idx < count) {
+			size = mail_get_physical_size(trashes[oldest_idx].mail);
+			if (size == (uoff_t)-1) {
+				/* maybe expunged already? */
+				trashes[oldest_idx].mail_set = FALSE;
+				continue;
+			}
+
 			if (mail_expunge(trashes[oldest_idx].mail) < 0)
 				break;
 
-			size = mail_get_physical_size(trashes[oldest_idx].mail);
-			if (size >= size_needed) {
-				size_needed = 0;
+			expunged_count++;
+			size_expunged += size;
+			if (size_expunged >= size_needed)
 				break;
-			}
 			trashes[oldest_idx].mail_set = FALSE;
-
-			size_needed -= size;
 		} else {
 			/* find more mails from next priority's mailbox */
 			i = j;
@@ -171,7 +175,7 @@
 		mail_free(&trash->mail);
 		(void)mailbox_search_deinit(&trash->search_ctx);
 
-		if (size_needed == 0) {
+		if (size_expunged >= size_needed) {
 			(void)mailbox_transaction_commit(&trash->trans,
 				MAILBOX_SYNC_FLAG_FULL_WRITE);
 		} else {
@@ -181,7 +185,15 @@
 
 		mailbox_close(&trash->box);
 	}
-	return size_needed == 0;
+
+	if (size_expunged < size_needed)
+		return FALSE;
+
+	ctx->bytes_current = ctx->bytes_current > size_expunged ?
+		ctx->bytes_current - size_expunged : 0;
+	ctx->count_current = ctx->count_current > expunged_count ?
+		ctx->count_current - expunged_count : 0;
+	return TRUE;
 }
 
 static int



More information about the dovecot-cvs mailing list