[Dovecot] ugly hack to make maildir quotas work

Joshua Goodall joshua at roughtrade.net
Thu Feb 16 08:07:50 EET 2006


Timo encouraged me to forward this to the list.  Basically it pokes
the right value into the right place to make quota deltas work properly
when saving mail to Maildirs.

It's a nasty hack workaround, so don't rely on it without understanding
that it should be superseded in future.

Without this, saving to a maildir doesn't increment quota.


--- src/lib-storage/index/maildir/maildir-save.c	14 Jan 2006 18:47:50 -0000	1.64
+++ src/lib-storage/index/maildir/maildir-save.c	16 Feb 2006 04:32:49 -0000
@@ -9,6 +9,7 @@
 #include "str.h"
 #include "maildir-storage.h"
 #include "maildir-uidlist.h"
+#include "index-mail.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -233,6 +234,7 @@
 	struct utimbuf buf;
 	const char *path;
 	int output_errno;
+	struct stat st;
 
 	if (ctx->failed && ctx->fd == -1) {
 		/* tmp file creation failed */
@@ -264,6 +266,9 @@
 					  "fsync(%s) failed: %m", path);
 		ctx->failed = TRUE;
 	}
+	if (fstat(ctx->fd, &st) < 0) {
+		ctx->failed = TRUE;
+	}
 	if (close(ctx->fd) < 0) {
 		mail_storage_set_critical(STORAGE(ctx->mbox->storage),
 					  "close(%s) failed: %m", path);
@@ -297,6 +302,8 @@
 
 		if (mail_set_seq(dest_mail, ctx->seq) < 0)
 			return -1;
+
+		((struct index_mail *)dest_mail)->data.physical_size = st.st_size;
 	}
 
 	t_pop();




/k

-- 
Josh "Koshua" Goodall                      "as modern as tomorrow afternoon"
joshua at roughtrade.net                                       - FW109


More information about the dovecot mailing list