Make newer() robust against missing source files

This commit is contained in:
Kovid Goyal 2023-02-03 16:58:13 +05:30
parent 839f977566
commit fed1d1b313
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -47,8 +47,12 @@ def newer(targets, sources):
if not os.path.exists(f):
return True
ttimes = map(lambda x: os.stat(x).st_mtime, targets)
stimes = map(lambda x: os.stat(x).st_mtime, sources)
newest_source, oldest_target = max(stimes), min(ttimes)
oldest_target = max(ttimes)
try:
stimes = map(lambda x: os.stat(x).st_mtime, sources)
newest_source = max(stimes)
except FileNotFoundError:
newest_source = oldest_target +1
return newest_source > oldest_target