changeset 4242:e05768db2fd7 HEAD

When requesting quota resource, don't return it if it's unlimited. Also treat 0 quota limits also in plugin parameters as unlimited.
author Timo Sirainen <tss@iki.fi>
date Tue, 02 May 2006 23:11:08 +0300
parents 4fa5cda580db
children 07c10799434e
files src/plugins/quota/quota-maildir.c
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/quota/quota-maildir.c	Tue May 02 23:01:33 2006 +0300
+++ b/src/plugins/quota/quota-maildir.c	Tue May 02 23:11:08 2006 +0300
@@ -512,6 +512,7 @@
 {
 	struct maildir_quota_root *root;
 	const char *const *args;
+	unsigned long long size;
 
 	root = i_new(struct maildir_quota_root, 1);
 	root->root.name = i_strdup(name);
@@ -525,12 +526,14 @@
 
 	for (; *args != '\0'; args++) {
 		if (strncmp(*args, "storage=", 8) == 0) {
-			root->message_bytes_limit =
-				strtoull(*args + 8, NULL, 10) * 1024;
+			size = strtoull(*args + 8, NULL, 10) * 1024;
+			if (size != 0)
+				root->message_bytes_limit = size;
 			root->master_message_limits = TRUE;
 		} else if (strncmp(*args, "messages=", 9) == 0) {
-			root->message_count_limit =
-				strtoull(*args + 9, NULL, 10);
+			size = strtoull(*args + 9, NULL, 10);
+			if (size != 0)
+				root->message_count_limit = size;
 			root->master_message_limits = TRUE;
 		}
 	}
@@ -595,14 +598,16 @@
 				 maildir_quota_root_get_storage(_root)) < 0)
 		return -1;
 
-	if (root->message_bytes_limit == (uint64_t)-1 &&
-	    root->message_count_limit == (uint64_t)-1)
-		return 0;
+	if (strcmp(name, QUOTA_NAME_STORAGE) == 0) {
+		if (root->message_bytes_limit == (uint64_t)-1)
+			return 0;
 
-	if (strcmp(name, QUOTA_NAME_STORAGE) == 0) {
 		*limit_r = root->message_bytes_limit / 1024;
 		*value_r = root->total_bytes / 1024;
 	} else if (strcmp(name, QUOTA_NAME_MESSAGES) == 0) {
+		if (root->message_count_limit == (uint64_t)-1)
+			return 0;
+
 		*limit_r = root->message_count_limit;
 		*value_r = root->total_count;
 	} else {