From 74f968d6ca24c57d942051bcd2bc764b1cb64ecc Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Sat, 6 Oct 2018 02:38:32 -0400 Subject: [PATCH] Correctly report error when target dir does not exist. If ./default.do knows how to build x/y/z, then we will run ./default.do x/y/z x/y/z x__y__z.redo2.tmp which can correctly generate $3, but then we can fail to rename it to x/y/z because x/y doesn't exist. This would previously through an exception. Now it prints a helpful error message. default.do may create x/y, in which case renaming will succeed. --- builder.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/builder.py b/builder.py index fe978fa..4c32583 100644 --- a/builder.py +++ b/builder.py @@ -244,7 +244,15 @@ class BuildJob: rv = 207 if rv==0: if st2: - os.rename(self.tmpname2, t) + try: + os.rename(self.tmpname2, t) + except OSError, e: + dnt = os.path.dirname(t) + if not os.path.exists(dnt): + err('%s: target dir %r does not exist!\n' % (t, dnt)) + else: + err('%s: rename %s: %s\n' % (t, self.tmpname2, e)) + raise os.unlink(self.tmpname1) elif st1.st_size > 0: try: