aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolaus Schulz <microschulz@web.de>2006-10-29 00:04:09 +0000
committerNikolaus Schulz <microschulz@web.de>2006-10-29 00:04:09 +0000
commit2dbd3c194025635321563bdcc4d6eec613138d83 (patch)
tree0099dd2b410cebac43964e36680dce4b092ae132
parente78b33e1154be20127938e8628910e2c1f00ec38 (diff)
downloadarchivemail-2dbd3c194025635321563bdcc4d6eec613138d83.tar.gz
archivemail-2dbd3c194025635321563bdcc4d6eec613138d83.tar.bz2
archivemail-2dbd3c194025635321563bdcc4d6eec613138d83.zip
Preparing per-testcase cleanup: made StaleFiles.clean() remember what it
deleted, so it's idempotent and e.g. doesn't stomp over someone else's files if invoked twice and running as root. Currently I don't see how this could happen, but it will with a per-testcase cleanup.
-rwxr-xr-xarchivemail.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/archivemail.py b/archivemail.py
index 8d25e43..1ac910a 100755
--- a/archivemail.py
+++ b/archivemail.py
@@ -131,19 +131,27 @@ class StaleFiles:
"""Delete any temporary files or lockfiles that exist"""
if self.procmail_lock:
vprint("removing stale procmail lock '%s'" % self.procmail_lock)
- try: os.remove(self.procmail_lock)
+ try:
+ os.remove(self.procmail_lock)
+ self.procmail_lock = None
except (IOError, OSError): pass
if self.retain:
vprint("removing stale retain file '%s'" % self.retain)
- try: os.remove(self.retain)
+ try:
+ os.remove(self.retain)
+ self.retain = None
except (IOError, OSError): pass
if self.archive:
vprint("removing stale archive file '%s'" % self.archive)
- try: os.remove(self.archive)
+ try:
+ os.remove(self.archive)
+ self.archive = None
except (IOError, OSError): pass
if self.temp_dir:
vprint("removing stale tempfile directory '%s'" % self.temp_dir)
- try: os.rmdir(self.temp_dir)
+ try:
+ os.rmdir(self.temp_dir)
+ self.temp_dir = None
except (IOError, OSError): pass