According to Jay Soffian:
>  Doesn't the presence of any messages in the new dir indicate "You
> have new mail." and the presence of any messages in the cur dir
> indicate "You have mail."

I wish, but the maildir manpage is clear on this:

  HOW A MESSAGE IS READ
       A mail reader operates as follows.

       It  looks through the new directory for new messages.  Say
       there is a new message, new/unique.  The reader may freely
       display  the contents of new/unique, delete new/unique, or
       rename     new/unique     as     cur/unique:info.

This means a mail reader may leave new messages in new/ if it wishes.

Now if a mail reader was obliged to move all new messages to cur/unique:info
before opening or deleting a message, you could use the mtime on cur/
as an indication of when the new mail was read.

So to find (a) when mail last arrived and (b) when mail was last checked
there are the following options:

1. Use atime on new/ for (a), and mtime on tmp/ for (b)
   Problem: some non-MUA programs scan new/ as well and change the
   atime on new/. They should be fixed.

2. Use mtime on cur/ for (a) and mtime on tmp/ for (b)
   Problem: all MUAs MUST move messages from new/ to cur/ first so
   that the mtime on cur/ gets updated.

3. Scan all files in new/ and cur/ with readdir(), then stat() them all
   and use the highest mtime for (a) and the highest atime for (b).
   Problem: this is the traditional method but can be very disk
   intensive because of all the stat()s. It is also more complicated to
   code - (1) and (2) are easy to drop in in existing applications.

My original proposal was (1). Now I get the feeling that (2) might
be better, but at least mutt and qmail-pop3d do things differently -
mutt leaves messages in new/ if not read, and qmail-pop3d deletes DELEted
messages directly from new/ without ever moving them to cur/

Now another solution would be:

4. Get mtime from tmp/, cur/ and new/. the mtime on tmp is (a): last time
   a new message arrived. MAX(mtime(cur), mtime(new)) defines (b): when the
   maildir mailbox was last checked for new mail.

   Problem: maildir(5) needs to state that a MUA MUST move the message
   new/unique to cur/unique:flags unless it is deleted.

This last proposal would work with most existing applications including
qmail-pop3d and applications that scan new/ and cur/. AFAICS, only
mutt would need to be fixed - a minor issue.

Remember why I started this: to be able to make shells and status bars
etc aware of maildir without big changes. Changing the app from stat()ing
the mbox to stat()ing maildir/{cur,tmp,new} is much easier, takes less
code and is more portable then to add a complete readdir() / stat() loop
to the application.

With just one added requirement for the MUA - it MUST move the message
new/unique to cur/unique:flags unless it is deleted - this would be possible.
Besides, most MUAs (including qmail-pop3d) behave this way already.

djb?

Mike.
-- 
Indifference will certainly be the downfall of mankind, but who cares?

Reply via email to