1
0
Fork 0
mirror of https://git.code.sf.net/p/archivemail/code synced 2024-12-23 08:14:58 +00:00

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.
This commit is contained in:
Nikolaus Schulz 2006-10-29 00:04:09 +00:00
parent e78b33e115
commit 2dbd3c1940

View file

@ -131,19 +131,27 @@ class StaleFiles:
"""Delete any temporary files or lockfiles that exist""" """Delete any temporary files or lockfiles that exist"""
if self.procmail_lock: if self.procmail_lock:
vprint("removing stale procmail lock '%s'" % 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 except (IOError, OSError): pass
if self.retain: if self.retain:
vprint("removing stale retain file '%s'" % 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 except (IOError, OSError): pass
if self.archive: if self.archive:
vprint("removing stale archive file '%s'" % 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 except (IOError, OSError): pass
if self.temp_dir: if self.temp_dir:
vprint("removing stale tempfile directory '%s'" % 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 except (IOError, OSError): pass