Skip to content

Commit 7399b32

Browse files
committed
fix: handle archives without info/files
Apparently it's possible for an archive to have only info/paths.json.
1 parent e9b50c1 commit 7399b32

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

rules/conda_package_repository.bzl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ load(
1111
"use_netrc",
1212
)
1313

14+
def _is_empty(ctx):
15+
"""Returns true if the metadata indicates that this is an empty archive."""
16+
files_list = ctx.path("info/files")
17+
if files_list.exists:
18+
return not ctx.read(files_list).strip()
19+
paths_json = ctx.path("info/paths.json")
20+
if not paths_json.exists:
21+
fail("Archive contained neither info/files nor info/paths.json")
22+
return not json.decode(ctx.read(paths_json)).get("paths")
23+
1424
def _conda_package_repository_impl(ctx):
1525
# Get this path here, because it might trigger a restart of the fetch,
1626
# which would be better to have happen before we download anything.
@@ -53,7 +63,7 @@ def _conda_package_repository_impl(ctx):
5363
ctx.delete("info-{}.tar.zst".format(ctx.attr.dist_name))
5464

5565
# Do not attempt to untar empty archives.
56-
if ctx.read("info/files").strip():
66+
if not _is_empty(ctx):
5767
ctx.extract("pkg-{}.tar.zst".format(ctx.attr.dist_name))
5868
ctx.delete("pkg-{}.tar.zst".format(ctx.attr.dist_name))
5969
else:

0 commit comments

Comments
 (0)