On 14.2.2012, at 5.31, Andy YB Hu wrote:
Now our system will take dovecot as the whole imap back end, and keep the LDA of ours, But our system has our own UID generation mechanism (in dovecot it's incremental from 1), which will be done while local delivery, So when local deliveries, it will first generate the UID, move the mail into maildir, then synchronize the mailbox index, which is part of dovecot LDA does. The question is what API or something else about index synchronization I can integrate into our own LDA program easily? Seems mailbox_copy() would be the possibility?
If you want it to be free of race conditions:
- Write the mail to tmp/
- Create dovecot-uidlist.lock
- Generate the UID and move the mail to new/ or cur/
- Append a line to dovecot-uidlist with your UID and the Maildir filename
- Delete dovecot-uidlist.lock
Although it sounds like the UID is generated before you can even create uidlist lock? That means IMAP client can at the same time generate a conflicting UID with APPEND/COPY. Also remember that UIDs must always be increasing. If you try to add a new message with lower UID then Dovecot won't like it, and even if you fix that, some IMAP clients may never see the mail.
Anyway, once you have uidlist updated you can do indexing/caching with e.g. "doveadm index" command in v2.0.