dovecot-1.1: quota_rule=?:.. specifies the default quota limits ...

dovecot at dovecot.org dovecot at dovecot.org
Tue Feb 26 16:27:26 EET 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/a39b16b0a530
changeset: 7295:a39b16b0a530
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Feb 26 16:29:46 2008 +0200
description:
quota_rule=?:.. specifies the default quota limits to use when backend
doesn't have any. If backend has limits, this rule is ignored.

diffstat:

3 files changed, 20 insertions(+), 22 deletions(-)
src/plugins/quota/quota-maildir.c |   30 +++++++++++-------------------
src/plugins/quota/quota-private.h |    2 ++
src/plugins/quota/quota.c         |   10 +++++++---

diffs (101 lines):

diff -r 9e4c26471b19 -r a39b16b0a530 src/plugins/quota/quota-maildir.c
--- a/src/plugins/quota/quota-maildir.c	Tue Feb 26 16:21:05 2008 +0200
+++ b/src/plugins/quota/quota-maildir.c	Tue Feb 26 16:29:46 2008 +0200
@@ -32,7 +32,6 @@ struct maildir_quota_root {
 	off_t last_size;
 
 	unsigned int limits_initialized:1;
-	unsigned int master_message_limits:1;
 };
 
 struct maildir_list_context {
@@ -290,7 +289,7 @@ static int maildirsize_recalculate_stora
 
 static void maildirsize_rebuild_later(struct maildir_quota_root *root)
 {
-	if (!root->master_message_limits) {
+	if (!root->root.force_default_rule) {
 		/* FIXME: can't unlink(), because the limits would be lost. */
 		return;
 	}
@@ -403,7 +402,7 @@ static int maildirsize_parse(struct mail
 	if (rule->bytes_limit == (int64_t)message_bytes_limit &&
 	    rule->count_limit == (int64_t)message_count_limit) {
 		/* limits haven't changed */
-	} else if (root->master_message_limits) {
+	} else if (root->root.force_default_rule) {
 		/* we know the limits and they've changed.
 		   the file must be rewritten. */
 		return 0;
@@ -551,22 +550,15 @@ static int maildirsize_read(struct maild
 
 static bool maildirquota_limits_init(struct maildir_quota_root *root)
 {
-	if (root->limits_initialized)
-		return root->maildirsize_path != NULL;
-	root->limits_initialized = TRUE;
-
-	/* these limits must be checked before the maildirsize is read the
-	   first time. if master limits aren't used, the default rule limits
-	   will be zero initially, but they'll be updated after the file is
-	   read. */
-	if (root->root.default_rule.bytes_limit != 0 ||
-	    root->root.default_rule.count_limit != 0)
-		root->master_message_limits = TRUE;
-
-	if (root->maildirsize_path == NULL) {
-		i_warning("quota maildir: No maildir storages, "
-			  "ignoring quota.");
-	}
+	if (!root->limits_initialized) {
+		root->limits_initialized = TRUE;
+
+		if (root->maildirsize_path == NULL) {
+			i_warning("quota maildir: No maildir storages, "
+				  "ignoring quota.");
+		}
+	}
+
 	return root->maildirsize_path != NULL;
 }
 
diff -r 9e4c26471b19 -r a39b16b0a530 src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h	Tue Feb 26 16:21:05 2008 +0200
+++ b/src/plugins/quota/quota-private.h	Tue Feb 26 16:29:46 2008 +0200
@@ -78,6 +78,8 @@ struct quota_root {
 
 	/* don't enforce quota when saving */
 	unsigned int no_enforcing:1;
+	/* Limits in default_rule override backend's quota limits */
+	unsigned int force_default_rule:1;
 };
 
 struct quota_transaction_context {
diff -r 9e4c26471b19 -r a39b16b0a530 src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Tue Feb 26 16:21:05 2008 +0200
+++ b/src/plugins/quota/quota.c	Tue Feb 26 16:29:46 2008 +0200
@@ -12,7 +12,8 @@
 #include <sys/wait.h>
 
 #define DEFAULT_QUOTA_EXCEEDED_MSG "Quota exceeded"
-#define RULE_NAME_ALL_MAILBOXES "*"
+#define RULE_NAME_DEFAULT_FORCE "*"
+#define RULE_NAME_DEFAULT_NONFORCE "?"
 
 struct quota_root_iter {
 	struct quota *quota;
@@ -341,9 +342,12 @@ int quota_root_add_rule(struct quota_roo
 
 	rule = quota_root_rule_find(root, mailbox_name);
 	if (rule == NULL) {
-		if (strcmp(mailbox_name, RULE_NAME_ALL_MAILBOXES) == 0)
+		if (strcmp(mailbox_name, RULE_NAME_DEFAULT_NONFORCE) == 0)
 			rule = &root->default_rule;
-		else {
+		else if (strcmp(mailbox_name, RULE_NAME_DEFAULT_FORCE) == 0) {
+			rule = &root->default_rule;
+			root->force_default_rule = TRUE;
+		} else {
 			rule = array_append_space(&root->rules);
 			rule->mailbox_name = p_strdup(root->pool, mailbox_name);
 		}


More information about the dovecot-cvs mailing list