From 2dbd3c194025635321563bdcc4d6eec613138d83 Mon Sep 17 00:00:00 2001 From: Nikolaus Schulz Date: Sun, 29 Oct 2006 00:04:09 +0000 Subject: 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. --- archivemail.py | 16 ++++++++++++---- 1 file 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 -- cgit v1.2.3