On Sat, 2007-09-29 at 19:43 -0300, "Fábio M. Catunda" wrote:
I'm almost there, look, from my log: FROM=Spam FILE=1191103168.P24773Q0M499718.fabio TO=INBOX
Looks perfect, but it's not. The real filename is 1191105530.P22847Q0M112390.fabio:2,Sa and not 1191103168.P24773Q0M499718.fabio
I'm using this function to get filename: filename = mail_get_special(mail, MAIL_FETCH_UIDL_FILE_NAME);
Anybody knows why the filename is returned incomplete?
Maildir filenames aren't stable. I suppose you could get it working most of the time by getting the current filename, but nothing guarantees that it hasn't changed already by the time you're trying to open it. You could get the current filename by using maildir-specific functions (like maildir_file_do() where the callback function would stat() the file, like maildir_mail_stat() works in maildir-mail.c).
You already mentioned something about using FIFOs. I'm not exactly sure how the dspam calling works, but I think FIFOs would be the best way to do this and also in mailbox format-independent way. If you do the spam training before COPY command finishes (i.e. in transaction_commit()), if something crashes in the middle you don't lose anything, because the entire COPY operation fails, and user tries it again later.