Barry Warsaw pushed to branch master at mailman / Mailman
Commits:
9b7a47db by Mark Sapiro at 2017-04-22T15:39:13-07:00
Enhance Switchboard.finish() to look for .pck if no .bak.
- - - - -
b2edcacc by Barry Warsaw at 2017-04-23T03:11:39+00:00
Merge branch 'finish' into 'master'
Enhance Switchboard.finish() to look for .pck if no .bak.
Closes #320
See merge request !262
- - - - -
2 changed files:
- src/mailman/core/switchboard.py
- src/mailman/core/tests/test_switchboard.py
Changes:
=====================================
src/mailman/core/switchboard.py
=====================================
--- a/src/mailman/core/switchboard.py
+++ b/src/mailman/core/switchboard.py
@@ -167,6 +167,13 @@ class Switchboard:
def finish(self, filebase, preserve=False):
"""See `ISwitchboard`."""
bakfile = os.path.join(self.queue_directory, filebase + '.bak')
+ # It is possible for a queue entry to be created by a non-Mailman user
+ # and not be readable by the Mailman user:group. If this happens, we
+ # get here and the file is a .pck rather than a .bak.
+ pckfile = os.path.join(self.queue_directory, filebase + '.pck')
+ if not os.path.isfile(bakfile) and os.path.isfile(pckfile):
+ # We have a .pck and not a .bak so switch the name for the next.
+ bakfile = pckfile
try:
if preserve:
bad_dir = config.switchboards['bad'].queue_directory
=====================================
src/mailman/core/tests/test_switchboard.py
=====================================
--- a/src/mailman/core/tests/test_switchboard.py
+++ b/src/mailman/core/tests/test_switchboard.py
@@ -17,6 +17,7 @@
"""Switchboard tests."""
+import os
import unittest
from mailman.config import config
@@ -51,3 +52,22 @@ Message-ID: <ant>
traceback = error_log.read().splitlines()
self.assertEqual(traceback[1], 'Traceback (most recent call last):')
self.assertEqual(traceback[-1], 'OSError: Oops!')
+
+ def test_no_bak_but_pck(self):
+ # if there is no .bak file but a .pck with the same filebase,
+ # .finish() should handle the .pck.
+ msg = mfs("""\
+From: [email protected]
+To: [email protected]
+Message-ID: <ant>
+
+""")
+ switchboard = config.switchboards['shunt']
+ # Enqueue the message.
+ filebase = switchboard.enqueue(msg)
+ # Now call .finish() without first dequeueing.
+ switchboard.finish(filebase, preserve=True)
+ # And ensure the file got preserved.
+ bad_dir = config.switchboards['bad'].queue_directory
+ psvfile = os.path.join(bad_dir, filebase + '.psv')
+ self.assertTrue(os.path.isfile(psvfile))
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/23be50d1555977438e295ab219109ee1d934d14a...b2edcaccbcf5778014b16139feb1a8eb6f31183e
---
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/23be50d1555977438e295ab219109ee1d934d14a...b2edcaccbcf5778014b16139feb1a8eb6f31183e
You're receiving this email because of your account on gitlab.com.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org