OfflineIMAP / offlineimap

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

Support expanding environment variables in Repository.localfolders as well #416

Closed darnir closed 7 years ago

darnir commented 7 years ago

General informations

Configuration file offlineimaprc

[Repository UdS-local]
type = Maildir
localfolders = $XDG_DATA_HOME/mail/UdS

Logs, error

OfflineIMAP 7.0.11
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
*** Processing account UdS
Establishing connection to mail.stud.uni-saarland.de:993 (UdS-remote)
Creating folder Trash[UdS-local]
Creating new Local Status db for UdS-local:Trash
Creating folder Trash[UdS-local]
Creating new Local Status db for UdS-local:Trash
ERROR: getfolder() asked for a nonexisting folder 'Drafts'.
*** Finished account 'UdS' in 0:01
ERROR: Exceptions occurred during the run!
ERROR: getfolder() asked for a nonexisting folder 'Drafts'.

Traceback:
  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 278, in syncrunner
    self.__sync()
  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 372, in __sync
    localfolder = self.get_local_folder(remotefolder)
  File "/usr/lib/python2.7/site-packages/offlineimap/accounts.py", line 307, in get_local_folder
    replace(self.remoterepos.getsep(), self.localrepos.getsep()))
  File "/usr/lib/python2.7/site-packages/offlineimap/repository/Maildir.py", line 149, in getfolder
    "folder '%s'."% foldername, OfflineImapError.ERROR.FOLDER)

Running strace shows:

stat("$XDG_DATA_HOME/mail/UdS/Trash", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
stat("$XDG_DATA_HOME/mail/UdS/Trash/cur", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
stat("$XDG_DATA_HOME/mail/UdS/Trash/new", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
stat("$XDG_DATA_HOME/mail/UdS/Trash/tmp", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
stat("$XDG_DATA_HOME/mail/UdS/", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
stat("$XDG_DATA_HOME/mail/UdS/cur", 0x7ffe7541acb0) = -1 ENOENT (No such file or directory)

It manages to create some of the required directories at first, but then fails. What is interesting however is the fact that "$XDG_DATA_HOME" was passed as-is instead of being expanded.

I know for a fact that $XDG_DATA_HOME is correctly set because i can see it in env and also because offlineimap correctly reads and writes its metadata to $XDG_DATA_HOME/offlineimap

Hence, the only remaining option is that offlineimap does not do environment variable expansion on repository.localfolder. Adding that support should not be too difficult though I guess

nicolas33 commented 7 years ago

Fixed by @darnir .