Use relative file paths in pickled mailboxes and gpg_home
JackDca opened this issue · 3 comments
Mailpile uses file path names relative to the homedir (Mailpile data directory) in the mailpile.cfg
file (e.g. /Mailpile$/mail/2d3fc
), where Mailpile$
is interpreted by the virtual file system as the homedir. But, in the pickled mailbox files (e.g. pickled-mailbox.000a) it uses absolute file paths (e.g. /home/snorri/.local/share/Mailpile/snorri/mail/a5b2d/new
). If the homedir is moved, this results in bad behaviour, for example if an email is deleted by a Mailpile that is running on the new homedir, it is the file in the old homedir location which is deleted.
A user might reasonably want to move a homedir, for example when restoring from backup, or when moving Mailpile to a new computer. It would be nice if Mailpile used relative file paths everywhere.
Happy ending: After discovering this issue by copying my production Mailpile homedir to a new location for use in development testing, I restored from backup, Mailpile rescanned my IMAP servers and everything is OK. Recent Sent emails are missing from the Sent folder but I use the default to BCC myself on outgoing emails so they are not lost.
Good catch! This is a very interesting issue. I absolutely agree we would like Mailpile's home directory to be relocatable.
In addition to the above, the parameter gpg_home
, stored in mailpile.rc
, is an absolute file path. As a result, it appears that if homedir
is moved, the new instance will continue to use the GnuPG keychain at the old location, which will cause problems. The title of this issue has been edited accordingly.
Note that the parameter homedir
, also stored in mailpile.rc
, is an absolute file path, but when Mailpile is launched it uses the environment variable MAILPILE_PROFILE
or MAILPILE_HOME
to override the value in mailpile.rc
.
On careful examination, most or all of the information in the pickled-mailbox*
files is redundant. Message locations given in these files are also defined in the Metadata Index and mailpile.cfg
. The Metadata Index location pointer (field 2) contains the file name and a pointer to a mailpile.cfg
parameter config/sources/[mail source]/mailbox/[mailbox]/local
that gives the relative path.
If it is desired to move a homedir
to a new location, the pickled-mailbox*
files can be deleted before starting Mailpile for the first time in the new homedir
. This prevents Mailpile from corrupting the mailboxes in the old homedir
. Mailpile will generate new pickled-mailbox*
files in the new homedir
It would nevertheless be cleaner to use relative paths in the pickled mailbox files.