[Imap-protocol] Childless noselect mailboxes
mrc+uw at Panda.COM
Tue Dec 29 11:02:01 PST 2009
On Tue, 29 Dec 2009, Timo Sirainen wrote:
> Dovecot with Maildir always behaved that way, but now that I'm creating
> a new mailbox format I thought I'd get rid of that restriction. But that
> in turn seems to be causing more trouble than I thought.
What, precisely, is the behavior that you purpose to do in these cases:
 "tag CREATE foo/"
 "tag DELETE foo" where foo is selectable and has a child?
 "tag DELETE foo/bar" where foo is \NoSelect and bar is the only
The requirements of IMAP in each case:
 An object named foo MUST be created, and that object MUST permit
children. That object MAY be \NoSelect.
 The child of foo MUST NOT be deleted. The mailbox foo is deleted, and
the name foo becomes \NoSelect.
 The mailbox bar is deleted.
As long as you comply with these requirements, you are fine. In the 
case, IMAP neither requires nor forbids deletion of foo. However, common
sense requires that if  creates foo as \NoSelect with no children, then
 should not delete foo. This is how a server that has "directories"
Similarly, if  creates foo as a selectable name, I would not be
surprised if  deletes foo. This is consistent with a server that does
not have "directories".
It would also be alright if  promotes foo to be selectable.
Think of things from the client side. If the server does not have
"directories", then the only way that it can have a \NoSelect superior is
if the client either implicitly created the superior or if the client
deleted the superior after it got children. A client which does either
should be assumed to be intelligent enough to understand IMAP's rules.
The bottom line is that a client MUST NOT expect a server to delete a
\NoSelect superior automatically, and MUST NOT be surprised if a server
If a client wants to keep "empty directories" around, it MUST NOT use the
implicit creation feature, and MUST NOT delete mailboxes with children
(if it wants to remove messages, use delete+expunge instead). Put another
way, the ONLY way it should make a directory is with the "tag CREATE foo/"
form. If that form makes a \NoSelect name, fine; but if it doesn't, then
don't force it.
I realize that the above is rather complex and probably requires
re-reading a few times before you fully grasp it. But I think that if you
think it through carefully, it'll make sense, seem reasonable, and not be
all that difficult to implement.
-- Mark --
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.
More information about the Imap-protocol