From b3ee9454b8b4c1cf44012cbf67d55247a8117937 Mon Sep 17 00:00:00 2001 From: shamilbi Date: Thu, 23 Oct 2025 17:17:20 +0200 Subject: [PATCH 1/3] +touch_file() --- morgan/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/morgan/utils.py b/morgan/utils.py index 425efc1..c8ca4e6 100644 --- a/morgan/utils.py +++ b/morgan/utils.py @@ -1,5 +1,7 @@ +import os import re +import dateutil # type: ignore[import-untyped] from packaging.requirements import Requirement @@ -42,3 +44,13 @@ def is_simple_case(self, req): if all(spec.operator in ('>', '>=') for spec in specifier._specs): return True return False + + +def touch_file(path: str, fileinfo: dict): + 'upload-time: 2025-05-28T18:46:29.349478Z' + time_str = fileinfo.get('upload-time') + if not path or not time_str: + return + dt = dateutil.parser.parse(time_str) + ts = dt.timestamp() + os.utime(path, (ts, ts)) From 456d1c3e8c59b60296d58906020b2434f4983d84 Mon Sep 17 00:00:00 2001 From: shamilbi Date: Thu, 23 Oct 2025 17:18:08 +0200 Subject: [PATCH 2/3] +touch_file(target, fileinfo) --- morgan/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/morgan/__init__.py b/morgan/__init__.py index 755fed9..abeb7ac 100644 --- a/morgan/__init__.py +++ b/morgan/__init__.py @@ -20,7 +20,7 @@ from morgan import configurator, metadata, server from morgan.__about__ import __version__ -from morgan.utils import Cache, to_single_dash +from morgan.utils import Cache, to_single_dash, touch_file PYPI_ADDRESS = "https://pypi.org/simple/" PREFERRED_HASH_ALG = "sha256" @@ -386,6 +386,7 @@ def _download_file( if os.path.exists(target): truehash = self._hash_file(target, hashalg) if truehash == exphash: + touch_file(target, fileinfo) return True print("\t{}...".format(fileinfo["url"]), end=" ") @@ -402,6 +403,7 @@ def _download_file( ) ) + touch_file(target, fileinfo) return True def _hash_file(self, filepath: str, hashalg: str) -> str: From 305914a38863e2022e5563a86fe931f37e75a8cc Mon Sep 17 00:00:00 2001 From: shamilbi Date: Thu, 23 Oct 2025 17:18:29 +0200 Subject: [PATCH 3/3] deps: +python-dateutil --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 0756ff5..e89ef59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ dependencies = [ # solved in morgan/__init__.py "importlib-metadata~=4.12.0; python_version < '3.8'", "tomli~=2.0.1", + "python-dateutil", ] classifiers = [ "Development Status :: 4 - Beta",