summaryrefslogtreecommitdiff
path: root/Mailman/Handlers/Scrubber.py
diff options
context:
space:
mode:
authorBarry Warsaw2007-10-10 23:22:03 -0400
committerBarry Warsaw2007-10-10 23:22:03 -0400
commit1ad73a52bb9d82ef3af1e34ad9ef66ac2eda2909 (patch)
tree7985eda24e60a39d58c54436e99f975610ee947d /Mailman/Handlers/Scrubber.py
parent15f9e73fdb96a145632e5916cc0073472c014c99 (diff)
downloadmailman-1ad73a52bb9d82ef3af1e34ad9ef66ac2eda2909.tar.gz
mailman-1ad73a52bb9d82ef3af1e34ad9ef66ac2eda2909.tar.zst
mailman-1ad73a52bb9d82ef3af1e34ad9ef66ac2eda2909.zip
Diffstat (limited to 'Mailman/Handlers/Scrubber.py')
-rw-r--r--Mailman/Handlers/Scrubber.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/Mailman/Handlers/Scrubber.py b/Mailman/Handlers/Scrubber.py
index 655742899..3f29fc02b 100644
--- a/Mailman/Handlers/Scrubber.py
+++ b/Mailman/Handlers/Scrubber.py
@@ -17,6 +17,8 @@
"""Cleanse a message for archiving."""
+from __future__ import with_statement
+
import os
import re
import sha
@@ -34,13 +36,13 @@ from email.generator import Generator
from email.parser import HeaderParser
from email.utils import make_msgid, parsedate
-from Mailman import LockFile
from Mailman import Message
from Mailman import Utils
from Mailman.Errors import DiscardMessage
from Mailman.app.archiving import get_base_archive_url
from Mailman.configuration import config
from Mailman.i18n import _
+from Mailman.lockfile import LockFile
# Path characters for common platforms
pre = re.compile(r'[/\\:]')
@@ -422,10 +424,7 @@ def save_attachment(mlist, msg, dir, filter_html=True):
ext = '.bin'
path = None
# We need a lock to calculate the next attachment number
- lockfile = os.path.join(fsdir, 'attachments.lock')
- lock = LockFile.LockFile(lockfile)
- lock.lock()
- try:
+ with LockFile(os.path.join(fsdir, 'attachments.lock')):
# Now base the filename on what's in the attachment, uniquifying it if
# necessary.
if not filename or config.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME:
@@ -461,8 +460,6 @@ def save_attachment(mlist, msg, dir, filter_html=True):
extra = '-%04d' % counter
else:
break
- finally:
- lock.unlock()
# `path' now contains the unique filename for the attachment. There's
# just one more step we need to do. If the part is text/html and
# ARCHIVE_HTML_SANITIZER is a string (which it must be or we wouldn't be