OfflineIMAP / offlineimap

Read/sync your IMAP mailboxes (python2) [LEGACY: move to offlineimap3]
http://www.offlineimap.org
Other
1.78k stars 361 forks source link

Why store the pid + hostname in the filename? #716

Closed vHanda closed 2 years ago

vHanda commented 2 years ago

Hello.

I noticed that the pid and hostname is being stored in the filename - https://github.com/OfflineIMAP/offlineimap/blob/7531ac4640aff8477b0893c55c99c9fe4a9bbcfc/offlineimap/folder/Maildir.py#L294 . I went back through the git history and I could trace it back to 5b5e6d0ef8cbb9f397c4d9df204c1d1d13572609 from 20 years ago, sadly the commit message doesn't really explain.

Is there any particular reason they are needed?

I have backups of old email accounts, and the filenames' reflect the different hostnames I've chosen over the years, I'm not sure if it matters that my hostname is now again different.

nicolas33 commented 2 years ago

I think there's no need for the hostname in the first place.

me-and commented 2 years ago

This is part of the Maildir standard, as documented at (for example) https://manpages.org/maildir/5

The Maildir standard is set up such that, even if there are multiple processes on multiple systems all writing to the same directory, they won't accidentally clobber each other's files. Including the PID means that multiple processes on the same system writing to the same directory can never clash; including the hostname means that processes on different systems writing to the same (shared) directory can also never clash.

It doesn't matter that the hostname recorded in the file name doesn't match any current system; that part of the filename has the sole purpose of making sure it's unique when it's created.

vHanda commented 2 years ago

@me-and Thank you for the wonderful explanation.

I'm closing this issue as I now understand.