[PATCH] maildir: Create top level dir recursively
Łukasz Żarnowiecki
dolohow at outlook.com
Wed Jun 1 17:25:27 BST 2016
This patch fixes the situation when "localfolders" specifies path that
is more that one level deep and top directory does not exists. Example
would be "localfolders = ~/Mail/a". This especially relevant on the
first run.
In that case we would end up with unhandled exception causing
unexpected termination of the program.
Thread 'Account sync test' terminated with exception:
Traceback (most recent call last):
File "/offlineimap/offlineimap/threadutil.py", line 172, in run
Thread.run(self)
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/offlineimap/offlineimap/accounts.py", line 258, in syncrunner
self.localrepos = Repository(self, 'local')
File "/offlineimap/offlineimap/repository/__init__.py", line 82, in __new__
return repo(name, account)
File "/offlineimap/offlineimap/repository/Maildir.py", line 40, in __init__
os.mkdir(self.root, 0o700)
OSError: [Errno 2] No such file or directory: '/Mail/a'
By replacing call to "mkdir" with "makedirs" we can simply create
directories recursively.
Signed-off-by: Łukasz Żarnowiecki <dolohow at outlook.com>
---
offlineimap/repository/Maildir.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/offlineimap/repository/Maildir.py b/offlineimap/repository/Maildir.py
index 10085e7..c30ffeb 100644
--- a/offlineimap/repository/Maildir.py
+++ b/offlineimap/repository/Maildir.py
@@ -37,7 +37,7 @@ class MaildirRepository(BaseRepository):
# Create the top-level folder if it doesn't exist
if not os.path.isdir(self.root):
- os.mkdir(self.root, 0o700)
+ os.makedirs(self.root, 0o700)
# Create the keyword->char mapping
self.keyword2char = dict()
--
2.8.3
More information about the OfflineIMAP-project
mailing list