[Dovecot] Disallow folder delete
Kenneth Porter
shiva at sewingwitch.com
Fri May 23 02:01:13 EEST 2008
On Wednesday, May 21, 2008 7:00 AM -0400 Charles Marcus
<CMarcus at Media-Brokers.com> wrote:
> On 5/20/2008 9:53 PM, Kenneth Porter wrote:
>> It might be nice to have a mode that disallows deletion of *non-empty*
>> folders. In order for a user to delete the folder, the folder must first
>> be emptied and purged.
>>
>> Alas, deleting messages can be undone, but folders can't be, and the UI
>> of a client doesn't necessarily make this obvious.
>
> Actually, a properly configured client will simply move the folder to the
> Trash - where the user can recover it if it was a mistake, unless/until
> the trash is empty.
This depends on the storage type. mbox can't hold a folder in a folder, so
where do you put a deleted folder if Trash is an mbox?
I looked at the 1.0.13 source and found that deleting a non-empty mbox
folder-to-hold-folders will fail (see mbox_mailbox_delete() in
mbox-storage.c), but a non-empty folder-to-hold-messages will succeed.
I think adding this to cmd-delete.c after the client workaround part should
prevent this. The message is taken from mbox_mailbox_delete but without the
folder name.
struct mailbox_status status;
if (mailbox_get_status(mailbox, 0, &status) < 0) {
return FALSE;
}
if (status.messages > 0)
{
client_send_tagline(cmd, "NO Folder isn't empty, can't delete it.");
return TRUE;
}
More information about the dovecot
mailing list