[Dovecot] More efficient Deleting of a whole folder (or Purging Trash)

Timo Sirainen tss at iki.fi
Thu Jan 31 15:38:35 EET 2008


On Thu, 2008-01-31 at 10:01 +0000, Daniel Watts wrote:
> Hi Timo,
> > On Jan 29, 2008, at 6:03 PM, Daniel Watts wrote:
> >
> >> Is there not a more efficient way to do this? If Dovecot knows the 
> >> whole folder is being deleted (ie a Trash purge), could it do 
> >> something clever with the filesystem to just remove the whole folder?
> >
> > If you use IMAP DELETE command, it renames the directory to 
> > ..DOVECOT-TRASH (or something like it) and only after that it starts 
> > unlinking the files. It wouldn't be too difficult to have this return 
> > success immediately and then keep deleting the files on the 
> > background. I'm not sure if this is worth the trouble though. It would 
> > also be possible to do this as a plugin.
> Something like that would be great. Would this actually then avoid the 
> locking problem described below?

Well, kind of, because the entire mailbox is deleted it can't even be
opened by another session :) Although it would be possible to create it
back immediately after deletion, but there's a small window during which
it's possible that the mailbox selection fails.

> IMHO this benefit is worth the effort. =)

There are two separate things here:

1) Making DELETE command work on background. This would require the user
to specifically delete + create back the mailbox and not just expunge
all messages. This wouldn't be too difficult.

2) Optimize expunging all messages by renaming Maildir/cur under
Maildir/tmp/, mkdir Maildir/cur back and then start deleting
Maildir/tmp/cur on background. This has a race condition between
rename() + mkdir(), so I don't want to ever do this by default.

Anyway I'm not going to implement either one anytime soon, but feel free
to write a plugin. :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://dovecot.org/pipermail/dovecot/attachments/20080131/301da755/attachment.bin 


More information about the dovecot mailing list