Skip to content

Commit b2480fa

Browse files
committed
update
1 parent 8ff0e05 commit b2480fa

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

Mailman/Archiver/HyperArch.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -892,10 +892,32 @@ def processUnixMailbox(self, archfile):
892892
"""Process a Unix mailbox file."""
893893
from email import message_from_file
894894
from mailbox import mbox
895-
mbox = mbox(archfile)
896-
for key in mbox.keys():
897-
msg = message_from_file(mbox.get_file(key))
898-
self.add_article(msg)
895+
896+
# If archfile is a file object, we need to read it directly
897+
if hasattr(archfile, 'read'):
898+
# Read the entire file content
899+
content = archfile.read()
900+
# Create a temporary file to store the content
901+
import tempfile
902+
with tempfile.NamedTemporaryFile(mode='w+', delete=False) as tmp:
903+
tmp.write(content)
904+
tmp_path = tmp.name
905+
906+
try:
907+
# Process the temporary file
908+
mbox = mbox(tmp_path)
909+
for key in mbox.keys():
910+
msg = message_from_file(mbox.get_file(key))
911+
self.add_article(msg)
912+
finally:
913+
# Clean up the temporary file
914+
os.unlink(tmp_path)
915+
else:
916+
# If it's a path, use it directly
917+
mbox = mbox(archfile)
918+
for key in mbox.keys():
919+
msg = message_from_file(mbox.get_file(key))
920+
self.add_article(msg)
899921

900922
def format_article(self, article):
901923
"""Format an article for HTML display."""

0 commit comments

Comments
 (0)