[Dovecot] Know when a Folder is Expunged or Deleted

Timo Sirainen tss at iki.fi
Wed Nov 3 15:59:57 EET 2010

On Wed, 2010-11-03 at 09:38 -0200, Alex Baule wrote:

> I try to do what you said, but i can't delete a folder from maildir, because
> the box->opened it's allways true.

It's supposed to be, yes.

>     if (!box->opened) {
>         i_warning("Empty Folder...");

No, box->opened doesn't mean it's empty. It means it's not a mailbox at
all. For example with mbox you could have:


Now you would have "archive" directory which would show up as
box->opened=FALSE, but "archive/2009" would be box->opened=TRUE,
regardless of how many messages it has.

If you want to check if the mailbox is empty, you need to check for it
manually with mailbox_status().

>         return zbox->super.delete(box);
>     }
>     i_warning("Full Folder...");
>     return -1;
> }
> Can i do that in "rename mailbox" function ? If Rename has .Trash in the
> name, i don't rename and return -1.

I'm not sure what you mean.. Yes, you can cancel a rename operation if
you want to.

> i Try too, don't let the user "move" one message from any folder to my
> "quarantine" folder, i intercept the copy function with a hook, but i only
> can do this, returning -1 in the copy function, but with -1 i will get a
> error message in the client like "Mailbox already exist" if i return 0 the
> source email is flaged as Trash and don't show anymore in the source
> folder... Can i do this, returning some value that works well and dont cause
> a client message ?

Use mail_storage_set_error() before returning -1.

More information about the dovecot mailing list