Skip to content

Commit

Permalink
Ensure repodata.json is updated for proxy channels
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
beenje committed Nov 30, 2023
1 parent 82285a6 commit 2c7749b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions quetz/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 2c7749b

Please sign in to comment.