Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: read index.json for snapshot package feeds #1080

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions asu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,11 @@
@app.get("/json/v1/{path:path}/{arch:path}-index.json")
@cache(expire=600)
def json_v1_arch_index(path: str, arch: str):
feeds = parse_feeds_conf(f"{settings.upstream_url}/{path}/{arch}")
packages = {}
feed_url: str = f"{settings.upstream_url}/{path}/{arch}"
feeds: list[str] = parse_feeds_conf(feed_url)
packages: dict[str, str] = {}

Check warning on line 85 in asu/main.py

View check run for this annotation

Codecov / codecov/patch

asu/main.py#L83-L85

Added lines #L83 - L85 were not covered by tests
for feed in feeds:
packages.update(
parse_packages_file(f"{settings.upstream_url}/{path}/{arch}/{feed}")[
"packages"
]
)

packages.update(parse_packages_file(f"{feed_url}/{feed}").get("packages", {}))

Check warning on line 87 in asu/main.py

View check run for this annotation

Codecov / codecov/patch

asu/main.py#L87

Added line #L87 was not covered by tests
return packages


Expand Down
7 changes: 6 additions & 1 deletion asu/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,12 @@


def parse_packages_file(url: str) -> dict[str, str]:
res: httpx.Response = httpx.get(f"{url}/Packages")
res: httpx.Response
if "/snapshots/" in url:
res = httpx.get(f"{url}/index.json")
return res.json() if res.status_code == 200 else {}

Check warning on line 334 in asu/util.py

View check run for this annotation

Codecov / codecov/patch

asu/util.py#L333-L334

Added lines #L333 - L334 were not covered by tests

res = httpx.get(f"{url}/Packages")
if res.status_code != 200:
return {}

Expand Down
Loading