improve previous about using mtime from imported maildir message files

don't treat just any number from filename as timestamp. require it has 2 dots.
prevents filenames with just a number as being seen as a timestamp, like when
you import files from a mox accounts msgs directory.
This commit is contained in:
Mechiel Lukkien 2024-04-02 20:04:09 +02:00
parent 6d38a1e9a4
commit ecf6163409
No known key found for this signature in database

View file

@ -309,8 +309,8 @@ func (mr *MaildirReader) Next() (*Message, *os.File, string, error) {
// Take received time from filename, falling back to mtime for maildirs // Take received time from filename, falling back to mtime for maildirs
// reconstructed some other sources of message files. // reconstructed some other sources of message files.
var received time.Time var received time.Time
t := strings.SplitN(filepath.Base(sf.Name()), ".", 2) t := strings.SplitN(filepath.Base(sf.Name()), ".", 3)
if v, err := strconv.ParseInt(t[0], 10, 64); err == nil { if v, err := strconv.ParseInt(t[0], 10, 64); len(t) == 3 && err == nil {
received = time.Unix(v, 0) received = time.Unix(v, 0)
} else if fi, err := sf.Stat(); err == nil { } else if fi, err := sf.Stat(); err == nil {
received = fi.ModTime() received = fi.ModTime()