I haven't been able to find what is responsible for altering the time on APPENDed mail, but was able to come up with a temporary workaround ... simply calling utime() later on in the process resolves it. Below is my patch. Steve --- dovecot-1.0.beta7-orig/src/lib-storage/index/maildir/maildir-save.c 2006-03-25 05:53:43.000000000 -0500 +++ dovecot-1.0.beta7/src/lib-storage/index/maildir/maildir-save.c 2006-04-19 09:47:32.000000000 -0400 @@ -70,9 +70,20 @@ t_strconcat(ctx->newdir, "/", basename, NULL) : t_strconcat(ctx->curdir, "/", dest, NULL); - if (link(tmp_path, new_path) == 0) + if (link(tmp_path, new_path) == 0) { ret = 0; - else { + if (ctx->received_date != (time_t)-1) { + struct utimbuf buf; + /* set the received_date by modifying mtime */ + buf.actime = ioloop_time; + buf.modtime = ctx->received_date; + if (utime(new_path, &buf) < 0) { + ctx->failed = TRUE; + mail_storage_set_critical(STORAGE(ctx->mbox->storage), + "utime(%s) failed: %m", new_path); + } + } + } else { ret = -1; if (ENOSPACE(errno)) { mail_storage_set_error(STORAGE(ctx->mbox->storage), @@ -332,18 +343,6 @@ t_push(); path = t_strconcat(ctx->tmpdir, "/", ctx->files->basename, NULL); - if (ctx->received_date != (time_t)-1) { - /* set the received_date by modifying mtime */ - buf.actime = ioloop_time; - buf.modtime = ctx->received_date; - - if (utime(path, &buf) < 0) { - ctx->failed = TRUE; - mail_storage_set_critical(STORAGE(ctx->mbox->storage), - "utime(%s) failed: %m", path); - } - } - output_errno = ctx->output->stream_errno; o_stream_destroy(&ctx->output);
Ok, this is looking less like a feature request and more like a bug report.
The function maildir_save_finish() in lib-storage/index/maildir/maildir-save.c is being passed the correct time information, and is setting the mtime properly with a call to utime().
It is doing this operation on a file that lives in /tmp.
For example:
-rw------- 1 121030 mail 26548 Mar 15 03:22 /var/mailstore/94/6d/121030/Maildir/.Deleted Messages/tmp/1145379992.P26598Q0M182281.dev3.neonova.net
Perfect. March 15th.
Something then happens... what, I haven't yet found... but the message gets moved from /tmp/:
/var/mailstore/94/6d/121030/Maildir/.Deleted Messages/cur/1145379992.P26598Q0M182281.dev3.neonova.net:2,S
and then loses the timestamp of March 15th ... it picks up the current date.
Steve
We're trying some migration tests ... from CommuniGate to Dovecot. The migration program does an APPEND into the new mailbox:
src>: a0 FETCH 2900 (FLAGS INTERNALDATE RFC822.PEEK) src<: * 2900 FETCH (FLAGS (\Seen) INTERNALDATE "29-Aug-2005 18:36:54 +0000" RFC822 {1194157} src<: ) dst>: bAPP APPEND "INBOX" (\Seen) "29-Aug-2005 18:36:54 +0000" {1194157} dst<: + OK
It appears to be trying to set the message date... in this example, to 29 Aug 2005.
Dovecot seems to be ignoring it.
Am I doing something wrong, or does Dovecot not allow this?
Steve