changeset 19941:c27d9577b06d

lazy-expunge: Code cleanup - move destination mailbox name generation to its own function
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Fri, 11 Mar 2016 17:57:41 +1300
parents 85c13ff0b958
children 9234cb74bc17
files src/plugins/lazy-expunge/lazy-expunge-plugin.c
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Wed Mar 16 09:27:04 2016 +0200
+++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c	Fri Mar 11 17:57:41 2016 +1300
@@ -66,12 +66,9 @@
 static MODULE_CONTEXT_DEFINE_INIT(lazy_expunge_mail_user_module,
 				  &mail_user_module_register);
 
-static struct mailbox *
-mailbox_open_or_create(struct mailbox_list *list, struct mailbox *src_box,
-		       const char **error_r)
+static const char *
+get_dest_vname(struct mailbox_list *list, struct mailbox *src_box)
 {
-	struct mailbox *box;
-	enum mail_error error;
 	const char *name;
 	char src_sep, dest_sep;
 
@@ -93,7 +90,18 @@
 		name = str_c(str);
 	}
 	/* add expunge namespace prefix. the name is now a proper vname */
-	name = t_strconcat(list->ns->prefix, name, NULL);
+	return t_strconcat(list->ns->prefix, name, NULL);
+}
+
+static struct mailbox *
+mailbox_open_or_create(struct mailbox_list *list, struct mailbox *src_box,
+		       const char **error_r)
+{
+	struct mailbox *box;
+	enum mail_error error;
+	const char *name;
+
+	name = get_dest_vname(list, src_box);
 
 	box = mailbox_alloc(list, name, MAILBOX_FLAG_NO_INDEX_FILES);
 	if (mailbox_open(box) == 0) {