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.
This commit is contained in:
Avery Pennarun 2018-10-06 02:38:32 -04:00
commit 74f968d6ca

View file

@ -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: