changeset 7970:bc5a85e2b11d HEAD

maildir: Add ,S=<size> to maildir filename with all quota backends.
author Timo Sirainen <tss@iki.fi>
date Tue, 08 Jul 2008 15:47:31 +0530
parents 2cd775b45b0c
children 7a6e72d2c599
files src/plugins/quota/quota-maildir.c src/plugins/quota/quota.c
diffstat 2 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/quota/quota-maildir.c	Tue Jul 08 14:52:19 2008 +0530
+++ b/src/plugins/quota/quota-maildir.c	Tue Jul 08 15:47:31 2008 +0530
@@ -676,25 +676,19 @@
 }
 
 static void
-maildir_quota_storage_added(struct quota *quota,
-			    struct mail_storage *_storage)
+maildir_quota_storage_added(struct quota *quota, struct mail_storage *storage)
 {
-	struct maildir_storage *storage =
-		(struct maildir_storage *)_storage;
 	struct quota_root **roots;
 	unsigned int i, count;
 
-	if (strcmp(_storage->name, "maildir") != 0)
+	if (strcmp(storage->name, "maildir") != 0)
 		return;
 
 	roots = array_get_modifiable(&quota->roots, &count);
 	for (i = 0; i < count; i++) {
 		if (roots[i]->backend.name == quota_backend_maildir.name)
-			maildir_quota_root_storage_added(roots[i], _storage);
+			maildir_quota_root_storage_added(roots[i], storage);
 	}
-
-	/* For newly generated filenames add ,S=size. */
-	storage->save_size_in_filename = TRUE;
 }
 
 static const char *const *
--- a/src/plugins/quota/quota.c	Tue Jul 08 14:52:19 2008 +0530
+++ b/src/plugins/quota/quota.c	Tue Jul 08 15:47:31 2008 +0530
@@ -4,6 +4,7 @@
 #include "array.h"
 #include "hash.h"
 #include "mailbox-list-private.h"
+#include "maildir-storage.h"
 #include "quota-private.h"
 #include "quota-fs.h"
 
@@ -424,6 +425,18 @@
 	return found;
 }
 
+static void quota_maildir_storage_set(struct mail_storage *storage)
+{
+	/* FIXME: a bit ugly location for this code. */
+	if (strcmp(storage->name, "maildir") == 0) {
+		/* For newly generated filenames add ,S=size. */
+		struct maildir_storage *mstorage =
+			(struct maildir_storage *)storage;
+
+		mstorage->save_size_in_filename = TRUE;
+	}
+}
+
 void quota_add_user_storage(struct quota *quota, struct mail_storage *storage)
 {
 	struct quota_root *const *roots;
@@ -433,6 +446,8 @@
 	unsigned int i, j, count;
 	bool is_file;
 
+	quota_maildir_storage_set(storage);
+
 	/* first check if there already exists a storage with the exact same
 	   path. we don't want to count them twice. */
 	path = mail_storage_get_mailbox_path(storage, "", &is_file);