Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
040472d8 by nerrehmit at 2020-12-02T23:57:40+00:00
Creates parent directory for digest.mmdf if not present

Checks if the path for the digest.mmdf file exists and creates the parent 
directory if not.

- - - - -
32c9dc70 by Mark Sapiro at 2020-12-02T23:57:41+00:00
Merge branch 'fix/missing-directory-699' into 'master'

Creates parent directory for digest.mmdf if not present

Closes #699

See merge request mailman/mailman!735
- - - - -


3 changed files:

- src/mailman/docs/NEWS.rst
- src/mailman/handlers/tests/test_to_digest.py
- src/mailman/handlers/to_digest.py


Changes:

=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -23,6 +23,8 @@ Bugs
 * Implemented a ``scrubber`` for plain text digests.  (Closes #473)
 * The ``mailman gatenews`` command now adds ``original_size`` as a message
   attribute.  (Extends fix for #762)
+* Handle FileNotFoundError when creating digest.mmdf file without
+  parent directory present (Closes #699)
 
 New Features
 ------------


=====================================
src/mailman/handlers/tests/test_to_digest.py
=====================================
@@ -51,3 +51,13 @@ Message-ID: <ant>
         # Make sure the digest mbox is not empty.
         mailbox_path = os.path.join(self._mlist.data_path, 'digest.mmdf')
         self.assertGreater(os.path.getsize(mailbox_path), 0)
+
+    def test_absent_parent_directory(self):
+        # Remove parent directory to setup for testing
+        os.rmdir(self._mlist.data_path)
+        # Call process function
+        self._msg.set_payload('test')
+        self._msg['X-Test'] = 'dummy'
+        self._handler.process(self._mlist, self._msg, {})
+        # Assert digest.mmdf parent directory is present
+        self.assertTrue(os.path.exists(self._mlist.data_path))


=====================================
src/mailman/handlers/to_digest.py
=====================================
@@ -43,6 +43,9 @@ class ToDigest:
             return
         # Open the mailbox that will be used to collect the current digest.
         mailbox_path = os.path.join(mlist.data_path, 'digest.mmdf')
+        # Create parent directory of 'digest.mmdf' if not present
+        if not os.path.exists(mlist.data_path):
+            os.mkdir(mlist.data_path)
         # Lock the mailbox and append the message.
         with Mailbox(mailbox_path, create=True) as mbox:
             mbox.add(msg)



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/6dd196a4b8a3c353023f14e17377b1f9380b7439...32c9dc70d0a6be08739619f5709140b0188494b8

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/6dd196a4b8a3c353023f14e17377b1f9380b7439...32c9dc70d0a6be08739619f5709140b0188494b8
You're receiving this email because of your account on gitlab.com.


_______________________________________________
Mailman-checkins mailing list -- mailman-checkins@python.org
To unsubscribe send an email to mailman-checkins-le...@python.org
https://mail.python.org/mailman3/lists/mailman-checkins.python.org/
Member address: arch...@jab.org

Reply via email to