[dovecot-cvs] dovecot/src/plugins/trash trash-plugin.c, 1.5.2.8, 1.5.2.9

tss at dovecot.org tss at dovecot.org
Thu Feb 22 15:38:41 UTC 2007


Update of /var/lib/cvs/dovecot/src/plugins/trash
In directory talvi:/tmp/cvs-serv17789

Modified Files:
      Tag: branch_1_0
	trash-plugin.c 
Log Message:
Fixes for handling multiple storages.



Index: trash-plugin.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/trash/trash-plugin.c,v
retrieving revision 1.5.2.8
retrieving revision 1.5.2.9
diff -u -d -r1.5.2.8 -r1.5.2.9
--- trash-plugin.c	22 Feb 2007 15:03:44 -0000	1.5.2.8
+++ trash-plugin.c	22 Feb 2007 15:38:39 -0000	1.5.2.9
@@ -46,7 +46,8 @@
 const char *trash_plugin_version = PACKAGE_VERSION;
 
 static void (*trash_next_hook_quota_root_created)(struct quota_root *root);
-static unsigned int trash_quota_module_id;
+static unsigned int trash_quota_module_id = 0;
+static bool trash_quota_module_id_set = FALSE;
 
 static pool_t config_pool;
 /* trash_boxes ordered by priority, highest first */
@@ -69,7 +70,7 @@
 	trash->box = mailbox_open(trash->storage, trash->name, NULL,
 				  MAILBOX_OPEN_KEEP_RECENT);
 	if (trash->box == NULL)
-		return -1;
+		return 0;
 
 	if (sync_mailbox(trash->box) < 0)
 		return -1;
@@ -116,14 +117,6 @@
 
 	trashes = array_get_modifyable(&trash_boxes, &count);
 	for (i = 0; i < count; ) {
-		if (trashes[i].storage == NULL) {
-			/* FIXME: this is really ugly. it'll do however until
-			   we get proper namespace support for lib-storage. */
-			struct mail_storage *const *storage;
-
-			storage = array_idx(&ctx->root->storages, 0);
-			trashes[i].storage = *storage;
-		}
 		/* expunge oldest mails first in all trash boxes with
 		   same priority */
 		oldest_idx = count;
@@ -132,7 +125,17 @@
 			if (trashes[j].priority != trashes[j].priority)
 				break;
 
-			ret = trash_clean_mailbox_get_next(&trashes[i],
+			if (trashes[j].storage == NULL) {
+				/* FIXME: this is really ugly. it'll do however
+				   until we get proper namespace support for
+				   lib-storage. */
+				struct mail_storage *const *storage;
+
+				storage = array_idx(&ctx->root->storages, 0);
+				trashes[j].storage = *storage;
+			}
+
+			ret = trash_clean_mailbox_get_next(&trashes[j],
 							   &received);
 			if (ret < 0)
 				goto __err;
@@ -301,7 +304,10 @@
 	root->v.try_alloc_bytes = trash_quota_root_try_alloc_bytes;
 	root->v.test_alloc_bytes = trash_quota_root_test_alloc_bytes;
 
-	trash_quota_module_id = quota_module_id++;
+	if (!trash_quota_module_id_set) {
+		trash_quota_module_id_set = TRUE;
+		trash_quota_module_id = quota_module_id++;
+	}
 	array_idx_set(&root->quota_module_contexts,
 		      trash_quota_module_id, &troot);
 }



More information about the dovecot-cvs mailing list