From e15e2599f10ad1ef945c7d0bda5a7e55711e489d Mon Sep 17 00:00:00 2001 From: Yanko Kaneti Date: Feb 23 2023 20:53:55 +0000 Subject: download-build: preserve build artefacts last modification time --- diff --git a/cli/koji_cli/lib.py b/cli/koji_cli/lib.py index 02c0cb9..73cb64d 100644 --- a/cli/koji_cli/lib.py +++ b/cli/koji_cli/lib.py @@ -12,6 +12,7 @@ import sys import time from contextlib import closing from copy import copy +from datetime import datetime import requests import six @@ -607,6 +608,12 @@ def download_file(url, relpath, quiet=False, noprogress=False, size=None, _download_progress(length, pos, filesize) if not length and not (quiet or noprogress): _download_progress(pos, pos, filesize) + last_modified = response.headers.get('last-modified') + if last_modified: + last_modified_pattern = "%a, %d %b %Y %H:%M:%S %Z" + mtime = int(datetime.strptime(last_modified, last_modified_pattern).timestamp()) + if mtime: + os.utime(relpath, (os.stat(relpath).st_atime, mtime)) finally: f.close() if pos == 0: