From 2c7749b912e093cac62c80b8e1b93ac7208504d0 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Thu, 30 Nov 2023 17:57:45 +0100 Subject: [PATCH] Ensure repodata.json is updated for proxy channels New version of mamba requests repodata.json.zst first. The compressed files are created locally when downloading the non compressed version. Quetz should always check if the repodata.json file needs to be re-downloaded so that all files stay consistent. --- quetz/main.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/quetz/main.py b/quetz/main.py index 9bd35574..89ccad5c 100644 --- a/quetz/main.py +++ b/quetz/main.py @@ -13,6 +13,7 @@ from concurrent.futures import ThreadPoolExecutor from contextlib import contextmanager from email.utils import formatdate +from pathlib import PurePath from tempfile import SpooledTemporaryFile, TemporaryFile from typing import Awaitable, Callable, List, Optional, Tuple, Type @@ -1818,12 +1819,20 @@ def serve_path( repository = RemoteRepository(channel.mirror_channel_url, session) if not pkgstore.file_exists(channel.name, path): download_remote_file(repository, pkgstore, channel.name, path) - elif path.endswith(".json"): + elif path.endswith((".json", ".json.bz2", ".json.gz", ".json.zst")): # repodata.json and current_repodata.json are cached locally # for channel.ttl seconds - _, fmtime, _ = pkgstore.get_filemetadata(channel.name, path) + # if one of the compressed file is requested, we check and download + # the non compressed version if needed + # (compressed files are created locally and should all have the same fmtime) + suffix = PurePath(path).suffix + if suffix == ".json": + json_path = path + else: + json_path = path[: -len(suffix)] + _, fmtime, _ = pkgstore.get_filemetadata(channel.name, json_path) if time.time() - fmtime >= channel.ttl: - download_remote_file(repository, pkgstore, channel.name, path) + download_remote_file(repository, pkgstore, channel.name, json_path) if ( is_package_request or pkgstore.kind == "LocalStore"