From 48ae1a36c89b30fe4c1efa2586a0d00dcfd61244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=C5=BBarnowiecki?= Date: Wed, 1 Jun 2016 18:25:27 +0200 Subject: [PATCH] maildir: Create top level dir recursively MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Nicolas Sebrecht --- 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()