dovecot-1.1: Maildir++ quota: If directory for maildirsize doesn...

dovecot at dovecot.org dovecot at dovecot.org
Mon Sep 22 21:50:37 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/14112c8e6a59
changeset: 7891:14112c8e6a59
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Sep 22 21:50:33 2008 +0300
description:
Maildir++ quota: If directory for maildirsize doesn't exist, create it.

diffstat:

1 file changed, 13 insertions(+)
src/plugins/quota/quota-maildir.c |   13 +++++++++++++

diffs (37 lines):

diff -r ad13463328aa -r 14112c8e6a59 src/plugins/quota/quota-maildir.c
--- a/src/plugins/quota/quota-maildir.c	Mon Sep 22 21:23:13 2008 +0300
+++ b/src/plugins/quota/quota-maildir.c	Mon Sep 22 21:50:33 2008 +0300
@@ -5,6 +5,7 @@
 #include "ioloop.h"
 #include "nfs-workarounds.h"
 #include "file-dotlock.h"
+#include "mkdir-parents.h"
 #include "read-full.h"
 #include "write-full.h"
 #include "str.h"
@@ -219,6 +220,7 @@ static int maildirsize_write(struct mail
 {
 	const struct quota_rule *rule = &root->root.default_rule;
 	struct dotlock *dotlock;
+	const char *p, *dir;
 	string_t *str;
 	int fd;
 
@@ -228,6 +230,17 @@ static int maildirsize_write(struct mail
 	dotlock_settings.nfs_flush = getenv("MAIL_NFS_STORAGE") != NULL;
 	fd = file_dotlock_open(&dotlock_settings, path,
 			       DOTLOCK_CREATE_FLAG_NONBLOCK, &dotlock);
+	if (fd == -1 && errno == ENOENT) {
+		/* the control directory doesn't exist yet? create it */
+		p = strrchr(path, '/');
+		dir = t_strdup_until(path, p);
+		if (mkdir_parents(dir, 0700) < 0 && errno != EEXIST) {
+			i_error("mkdir_parents(%s) failed: %m", dir);
+			return -1;
+		}
+		fd = file_dotlock_open(&dotlock_settings, path,
+				       DOTLOCK_CREATE_FLAG_NONBLOCK, &dotlock);
+	}
 	if (fd == -1) {
 		if (errno == EAGAIN) {
 			/* someone's just in the middle of updating it */


More information about the dovecot-cvs mailing list