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

dovecot at dovecot.org dovecot at dovecot.org
Mon Sep 22 21:51:33 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/f67d4a0d423b
changeset: 8208:f67d4a0d423b
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Sep 22 21:51:29 2008 +0300
description:
Maildir++ quota: If directory for maildirsize doesn't exist, create it.

diffstat:

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

diffs (38 lines):

diff -r 2442529e4cec -r f67d4a0d423b src/plugins/quota/quota-maildir.c
--- a/src/plugins/quota/quota-maildir.c	Mon Sep 22 21:23:37 2008 +0300
+++ b/src/plugins/quota/quota-maildir.c	Mon Sep 22 21:51:29 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"
@@ -221,6 +222,7 @@ static int maildirsize_write(struct mail
 	struct mail_storage *const *storages;
 	unsigned int i, count;
 	struct dotlock *dotlock;
+	const char *p, *dir;
 	string_t *str;
 	mode_t mode;
 	gid_t gid;
@@ -246,6 +248,18 @@ static int maildirsize_write(struct mail
 	fd = file_dotlock_open_mode(&dotlock_settings, path,
 				    DOTLOCK_CREATE_FLAG_NONBLOCK,
 				    mode, (uid_t)-1, gid, &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_mode(&dotlock_settings, path,
+					    DOTLOCK_CREATE_FLAG_NONBLOCK,
+					    mode, (uid_t)-1, gid, &dotlock);
+	}
 	if (fd == -1) {
 		if (errno == EAGAIN) {
 			/* someone's just in the middle of updating it */


More information about the dovecot-cvs mailing list