summaryrefslogtreecommitdiff
path: root/src/mailman/archiving/pipermail.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/archiving/pipermail.py')
-rw-r--r--src/mailman/archiving/pipermail.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/mailman/archiving/pipermail.py b/src/mailman/archiving/pipermail.py
index 377f4ab53..42a89ea55 100644
--- a/src/mailman/archiving/pipermail.py
+++ b/src/mailman/archiving/pipermail.py
@@ -26,6 +26,8 @@ __all__ = [
import os
+import mailbox
+import tempfile
from cStringIO import StringIO
from zope.interface import implements
@@ -111,11 +113,18 @@ class Pipermail:
@staticmethod
def archive_message(mlist, message):
"""See `IArchiver`."""
- text = str(message)
- fileobj = StringIO(text)
+ fd, path = tempfile.mkstemp('.mbox')
+ os.close(fd)
+ try:
+ mbox = mailbox.mbox(path, create=True)
+ mbox.add(message)
+ finally:
+ mbox.close()
h = HyperArchive(IPipermailMailingList(mlist))
- h.processUnixMailbox(fileobj)
- h.close()
- fileobj.close()
+ try:
+ h.processUnixMailbox(path)
+ finally:
+ h.close()
+ os.remove(path)
# There's no good way to know the url for the archived message.
return None