# HG changeset patch # User Timo Sirainen # Date 1457672493 -46800 # Node ID 9234cb74bc17a200db82e8213af1dc33d7a96126 # Parent c27d9577b06d425a844a611e660b0bae752742dc lazy-expunge: If lazy_expunge is set to namespace root, save all mails to the root mailbox. So the difference is: namespace { prefix = expunged/ .. } plugin { # Move expunged mails to expunged/INBOX, expunged/Trash, etc. mailboxes lazy_expunge = expunged/ # Move all expunged mails to "expunged" mailbox, which is the namespace root. lazy_expunge = expunged } diff -r c27d9577b06d -r 9234cb74bc17 src/plugins/lazy-expunge/lazy-expunge-plugin.c --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c Fri Mar 11 17:57:41 2016 +1300 +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c Fri Mar 11 18:01:33 2016 +1300 @@ -31,6 +31,7 @@ union mail_user_module_context module_ctx; struct mail_namespace *lazy_ns; + const char *lazy_mailbox_vname; const char *env; bool copy_only_last_instance; }; @@ -69,9 +70,14 @@ static const char * get_dest_vname(struct mailbox_list *list, struct mailbox *src_box) { + struct lazy_expunge_mail_user *luser = + LAZY_EXPUNGE_USER_CONTEXT(list->ns->user); const char *name; char src_sep, dest_sep; + if (luser->lazy_mailbox_vname != NULL) + return luser->lazy_mailbox_vname; + /* use the (canonical / unaliased) storage name */ name = src_box->name; /* replace hierarchy separators with destination virtual separator */ @@ -435,6 +441,13 @@ return; luser->lazy_ns = mail_namespace_find_prefix(namespaces, luser->env); + if (luser->lazy_ns == NULL) { + /* see if it's set to namespace root itself. in that case we + store all the expunged mails to the namespace root. */ + luser->lazy_ns = mail_namespace_find_prefix_nosep(namespaces, luser->env); + luser->lazy_mailbox_vname = p_strndup(namespaces->user->pool, + luser->lazy_ns->prefix, luser->lazy_ns->prefix_len-1); + } if (luser->lazy_ns == NULL) i_fatal("lazy_expunge: Unknown namespace: '%s'", luser->env); mail_namespace_ref(luser->lazy_ns);