From 588da38bee809b2b756b811e2be0d3ed4900c163 Mon Sep 17 00:00:00 2001 From: balki <3070606-balki@users.noreply.gitlab.com> Date: Tue, 18 Dec 2018 17:12:04 -0500 Subject: [PATCH] Create Maildir subdir python stdlib bug: They are not created automatically when the parent is present python stdlib bug: Add comment to `import encodings.idna` --- mail4one/server.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mail4one/server.py b/mail4one/server.py index 5bcbfb7..914a66c 100644 --- a/mail4one/server.py +++ b/mail4one/server.py @@ -8,6 +8,9 @@ import sys from argparse import ArgumentParser from functools import partial from pathlib import Path + +# Though we don't use requests, without the below import, we crash https://stackoverflow.com/a/13057751 +# When running on privilege port after dropping privileges. # noinspection PyUnresolvedReferences import encodings.idna @@ -58,8 +61,11 @@ class MaildirCRLF(mailbox.Maildir): class MailboxCRLF(Mailbox): - def __init__(self, mail_dir): + def __init__(self, mail_dir: Path): super().__init__(mail_dir) + for sub in ('new', 'tmp', 'cur'): + sub_path = mail_dir / sub + sub_path.mkdir(mode=0o755, exist_ok=True, parents=True) self.mailbox = MaildirCRLF(mail_dir)