Print mtime before updating file metadata

This commit is contained in:
I-Al-Istannen 2023-09-23 12:37:56 +02:00
parent 533bc27439
commit 03efa17cf1
2 changed files with 4 additions and 0 deletions

View File

@ -514,8 +514,11 @@ class IliasPage:
f"td.std:nth-child({index})"
).getText().strip()
if re.search(r"\d+\.\d+.\d+ - \d+:\d+", modification_string):
log.explain(f"Converting {modification_string!r}")
modification_time = datetime.strptime(modification_string, "%d.%m.%Y - %H:%M")
break
else:
log.explain(f"Date has wrong format: {modification_string!r}")
if modification_time is None:
log.warn(f"Could not determine upload time for {link}")

View File

@ -415,6 +415,7 @@ class OutputDirectory:
def _update_metadata(self, info: DownloadInfo) -> None:
if mtime := info.heuristics.mtime:
log.explain(f"Setting mtime to {mtime}")
mtimestamp = mtime.timestamp()
os.utime(info.local_path, times=(mtimestamp, mtimestamp))