diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-06 18:32:01 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-06 18:32:01 +0000 |
commit | 6370812b4277134b3c5cd143b20adc8c94890b91 (patch) | |
tree | 7ca3ea12a66dbea7fb28b49e68f85264bc04596b /tools/ccc/ccclib/Driver.py | |
parent | 100f402451da96f74ea58b1f49fc53b4fa149a57 (diff) |
Tidy file removal cleanup & remove race condition on file existence.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66281 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/ccc/ccclib/Driver.py')
-rw-r--r-- | tools/ccc/ccclib/Driver.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/tools/ccc/ccclib/Driver.py b/tools/ccc/ccclib/Driver.py index 2015b2f0ed..25984dd74e 100644 --- a/tools/ccc/ccclib/Driver.py +++ b/tools/ccc/ccclib/Driver.py @@ -229,19 +229,27 @@ class Driver(object): self.executeJobs(args, jobs) except: if not args.getLastArg(self.parser.saveTempsOption): - for f in self.resultFiles: - # Fail if removing a result fails: - if os.path.exists(f): - os.remove(f) + # Fail if removing a result fails. + self.removeFiles(self.resultFiles, failOnError=True) raise finally: for f in self.tempFiles: # Ignore failures in removing temporary files - try: - os.remove(f) - except: - pass - + self.removeFiles(self.resultFiles, failOnError=False) + + def removeFiles(self, fileList, failOnError=False): + for f in fileList: + try: + os.remove(f) + except OSError,e: + if failOnError: + import errno + if e.errno != errno.ENOENT: + raise + except: + if failOnError: + raise + def executeJobs(self, args, jobs): vArg = args.getLastArg(self.parser.vOption) for j in jobs.iterjobs(): |