[Dovecot] deleting maildir files

Don Russell russell.don at gmail.com
Tue Jul 17 19:23:25 EEST 2007


Kirill Miazine wrote:
> * Don Russell [2007-07-16 10:23]:
>>> Can we delete maildir files directly from the file system?
> [...]
>>> And if we cannot delete files with the 'rm' command, whats the
>>> best/proper way to delete these older files.
>>
>> My opinion has always been that the data structure should not be 
>> replied upon.... if you want to do things with your mail items, then 
>> use the APIs/imap commands to do it. That protects you from any 
>> internal stuff you didn't know about, or changed from one server to 
>> another, or one version to another.
>
> Maildir is a sort of a standard with some sort of an API, isn't it? The
> "standard" (<http://cr.yp.to/proto/maildir.html>) says following:
>
>     An MUA can read and delete messages while new mail is being
>     delivered: each message is stored in a separate file with a
>     unique name, so it isn't affected by operations on other messages.

True, but why tie my script to one format, when it can work equally well 
with *any* format supported by the IMAP server? :-) If new and improved 
formats develop, I don't have to rewrite my scripts. :-)

>
>> For example, I have the beginnings of a script to handle my "mail 
>> retention policies". It connects to Dovecot/imap to get the list of 
>> mail for specific folders, then uses the imap delete (or copy) API to 
>> delete mail older than n days, or to keep only the most recent n 
>> messages. That sort of thing.
>
> With Maildir it's trivial to do this sort of things with a shell script.

Yes, I suppose it is. :-) However, in my case (and I wrote the script 
for my own use) my mail is in mbox format. Eventually I want to convert 
it to maildir or something else (dbox?) and since my script uses the 
IMAP interface, I won't have to change anything, the IMAP server does 
all the heavy lifting. :-)

>
>> The benefit is my script then doesn't care how Dovecot (or whichever 
>> server) stores things.... and if a mailbox changes from mbox to 
>> maildir format, or similar change.. no worries... my script just 
>> doesn't care... it always uses the APIs to manipulate mail.
>>
>> Safe, but admittedly not as fast. I favor reliability over speed in 
>> these sorts of cases.  :-)
>
> That's a valid point. It's much easier to shoot one's own leg pretty
> ugly, when deleting/renaming/whatevert the files in the Maildir
> directly. IMAP SEARCH is IMHO a bit easier to understand than find(1).
>
> Best wishes,
> Kirill
>

Cheers :-)


More information about the dovecot mailing list