summaryrefslogtreecommitdiff
path: root/Mailman
diff options
context:
space:
mode:
authorklm1998-11-05 00:46:39 +0000
committerklm1998-11-05 00:46:39 +0000
commit3102ac8a232768ff2f6e4229e685954eda79e69b (patch)
tree2153dcbe4bab7c452c7ecf8eecc4e9a6439a2d03 /Mailman
parentdf640bacf3de4c1684a77fe6e1442bd767bff092 (diff)
downloadmailman-3102ac8a232768ff2f6e4229e685954eda79e69b.tar.gz
mailman-3102ac8a232768ff2f6e4229e685954eda79e69b.tar.zst
mailman-3102ac8a232768ff2f6e4229e685954eda79e69b.zip
.ArchiveMail(): Finally doing the right thing regarding exceptions
occurring within the child process. We need a 'finally: os._exit()' to ensure that we don't return twice to parent processes that happen to handle exceptions (like the post script does), but we also need to do something to report the exception, since the 'finally: os._exit()' will prevent getting back to the top level, where uncaught exceptions would be printed to stdout. The answer is to wrap a 'try...finally' around a 'try...except' that uses traceback.print_exc() to print the traceback to stderr. Now we won't get mutiple returns from the script in case of exceptions, but the exception will be reported. .ArchiveMail(), .CheckHTMLArchiveDir(): Respect new -1 value for ARCHIVE_TO_MBOX, meaning disable all archiving (for those who, eg, don't want to expend the disk space - or those who can't get it to work without errors;-). Yes, the '-1' value is bogus - but the consolidation of html vs mbox saving using a single var, and without an option to disable completely, is more bogus:-) I'll suggest an alternative in my checkin of Defaults.py.in. .__archive_to_mbox(): the message being logged in the IOError exception case had a bad index, causing another exception.
Diffstat (limited to 'Mailman')
-rw-r--r--Mailman/Archiver/Archiver.py56
1 files changed, 33 insertions, 23 deletions
diff --git a/Mailman/Archiver/Archiver.py b/Mailman/Archiver/Archiver.py
index bcf745706..a619bc28e 100644
--- a/Mailman/Archiver/Archiver.py
+++ b/Mailman/Archiver/Archiver.py
@@ -171,7 +171,7 @@ class Archiver:
except IOError, msg:
self.LogMsg("error", ("Archive file access failure:\n"
"\t%s %s"
- % (afn, `msg[1]`)))
+ % (afn, `msg`)))
reraise(msg)
if self.clobber_date:
# Resurrect original date setting.
@@ -183,31 +183,39 @@ class Archiver:
def ArchiveMail(self, msg):
"""Store postings in mbox and/or pipermail archive, depending."""
# Fork so archival errors won't disrupt normal list delivery
+ if mm_cfg.ARCHIVE_TO_MBOX == -1:
+ return
if os.fork():
return
# archive to builtin html archiver
- if mm_cfg.ARCHIVE_TO_MBOX in [1, 2]:
- self.__archive_to_mbox(msg)
- if mm_cfg.ARCHIVE_TO_MBOX == 1:
- # Archive to mbox only.
- os._exit(0)
+ import traceback
try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
- txt = msg.unixfrom
- for h in msg.headers:
- txt = txt + h
- if msg.body[0] != '\n':
- txt = txt + "\n"
- txt = txt + msg.body
- f = StringIO(txt)
- import HyperArch
- h = HyperArch.HyperArchive(self)
- h.processUnixMailbox(f, HyperArch.Article)
- h.close()
- f.close()
- os._exit(0)
+ try:
+ if mm_cfg.ARCHIVE_TO_MBOX in [1, 2]:
+ self.__archive_to_mbox(msg)
+ if mm_cfg.ARCHIVE_TO_MBOX == 1:
+ # Archive to mbox only.
+ os._exit(0)
+ try:
+ from cStringIO import StringIO
+ except ImportError:
+ from StringIO import StringIO
+ txt = msg.unixfrom
+ for h in msg.headers:
+ txt = txt + h
+ if msg.body[0] != '\n':
+ txt = txt + "\n"
+ txt = txt + msg.body
+ f = StringIO(txt)
+ import HyperArch
+ h = HyperArch.HyperArchive(self)
+ h.processUnixMailbox(f, HyperArch.Article)
+ h.close()
+ f.close()
+ except:
+ traceback.print_exc(file=sys.stderr)
+ finally:
+ os._exit(0)
#
# called from MailList.MailList.Save()
@@ -221,7 +229,9 @@ class Archiver:
# the directory, it's pointless to try to
# fix the perms, so we just return -scott
#
- #
+ if mm_cfg.ARCHIVE_TO_MBOX == -1:
+ # Archiving is completely disabled, don't require the skeleton.
+ return
pubdir = os.path.join(self.public_archive_file_dir,
self._internal_name)
privdir = self.archive_directory