rebuild only files that need re-building

we compare the mtimes of src and dst
This commit is contained in:
Bastian Venthur
2022-08-06 21:56:41 +02:00
parent 6e94a0c094
commit a939e6503c

View File

@@ -293,6 +293,18 @@ def process_markdown(convertibles, input_dir, output_dir,
for src, dst in convertibles: for src, dst in convertibles:
logger.debug(f'Processing {src}') logger.debug(f'Processing {src}')
# see first if the dst actually needs re-building. for that we compare
# the mtimes and assume mtime_dst > mtime_src means that it needs not
# to be rebuilt
if os.path.exists(f'{output_dir}/{dst}'):
mtime_src = os.stat(f'{input_dir}/{src}').st_mtime
mtime_dst = os.stat(f'{output_dir}/{dst}').st_mtime
if mtime_dst >= mtime_src:
logger.debug(
'Skipping, as target exists and is newer than source.'
)
continue
with open(f'{input_dir}/{src}', 'r') as fh: with open(f'{input_dir}/{src}', 'r') as fh:
body = fh.read() body = fh.read()