From 49f0a041b278ea9e6421628ef1971147c2c6cc12 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Sat, 11 Dec 2010 21:10:57 -0800 Subject: [PATCH] clean.do: cleanup *.tmp files that might have been left lying around. ...and fix a bug where builder.py can't handle it if its temp file is deleted out from under it. --- builder.py | 8 +++++++- clean.do | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/builder.py b/builder.py index 9878e86..0dacc1a 100644 --- a/builder.py +++ b/builder.py @@ -211,7 +211,13 @@ class BuildJob: os.rename(self.tmpname2, t) os.unlink(self.tmpname1) elif st1.st_size > 0: - os.rename(self.tmpname1, t) + try: + os.rename(self.tmpname1, t) + except OSError, e: + if e.errno == errno.ENOENT: + unlink(t) + else: + raise if st2: os.unlink(self.tmpname2) else: # no output generated at all; that's ok diff --git a/clean.do b/clean.do index 311be33..dfebaed 100644 --- a/clean.do +++ b/clean.do @@ -6,3 +6,4 @@ fi redo t/clean rm -f *~ .*~ */*~ */.*~ *.pyc rm -rf t/.redo +find -name '*.tmp' -exec rm -fv {} \;