Description
The time prefixes on the message file names generated with -t
(use envelope timestamp) are off by one name. The time stamp used to name the current message file is the time stamp of the previous message file. The first message file, having no previous time stamp, is missing the leading time stamp. The modification times of the message files are set correctly; only the names are off-by-one.
$ ./mb2md.pl -S -t -m -d foo
[...]
28092 messages.
$ find foo/new -type f -printf '%T@ %f\n' | head
1088656864.0000000000 1733138021.000000.mbox,S=6215:2,S
1090650675.0000000000 1088656864-1733138021.000001.mbox,S=4254:2,S
1092261667.0000000000 1090650675-1733138021.000002.mbox,S=5627:2,S
1092620882.0000000000 1092261667-1733138021.000003.mbox,S=7573:2,S
1095337264.0000000000 1092620882-1733138021.000004.mbox,S=19384:2,RS
1095343564.0000000000 1095337264-1733138021.000005.mbox,S=10747:2,RS
1108069867.0000000000 1095343564-1733138021.000006.mbox,S=3082:2,S
1108931944.0000000000 1108069867-1733138021.000007.mbox,S=3416:2,RS
1122610266.0000000000 1108931944-1733138021.000008.mbox,S=17709:2,RS
1122654065.0000000000 1122610266-1733138021.000009.mbox,S=3510:2,RS
Note that the incorrect leading time field on each message file name, except the first, is the modification time of the previous message file. The leading time field should be modification time of the message itself, not of the previous message. This is also true under foo/cur:
$ find foo/cur -type f -printf '%T@ %f\n' | head
1233599477.0000000000 1232548864-1733138021.000050.mbox,S=3856:2,S
1234325462.0000000000 1233599477-1733138021.000051.mbox,S=5728:2,S
1234326062.0000000000 1234325462-1733138021.000052.mbox,S=5958:2,S
1234588863.0000000000 1234326062-1733138021.000053.mbox,S=2275:2,S
1234588862.0000000000 1234588863-1733138021.000054.mbox,S=7608:2,S
1234983075.0000000000 1234588862-1733138021.000055.mbox,S=4260:2,RS
1236186063.0000000000 1234983075-1733138021.000056.mbox,S=5969:2,RS
1236208263.0000000000 1236186063-1733138021.000057.mbox,S=4926:2,S
1238711464.0000000000 1236208263-1733138021.000058.mbox,S=4741:2,RS
1238714464.0000000000 1238711464-1733138021.000059.mbox,S=5152:2,S
This happens because the $messagefn
is used to create the new message file before the $filebase
is set to the correct prefix. $filebase
is only set after the file is closed. The fix is to move the code to set $filebase
up to where $receivedate
is set, before the message file is opened.