Skip to content

Add .conda package reader - #32

Merged
andrew merged 1 commit into
mainfrom
conda
Aug 16, 2026
Merged

Add .conda package reader#32
andrew merged 1 commit into
mainfrom
conda

Conversation

@andrew

@andrew andrew commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Based on #31.

The v2 conda format is an uncompressed zip containing metadata.json, pkg-<name>.tar.zst and info-<name>.tar.zst. Both inner tarballs already store their entries with the paths that appear in the equivalent v1 .tar.bz2 package (info/ is a prefix inside the tar, not something to add), so openConda opens each .tar.zst member through openTar and concatenates the entries into a single tar view. Hash covers the outer .conda bytes, matching what anaconda.org publishes in repodata.json.

Decompressed size is capped cumulatively across all members so a zip with many pkg-*/info-* entries cannot exceed maxDecompressedSize by staying under it per member.

Verified against six-1.17.0-pyhd8ed1ab_0.conda from conda-forge: 25 merged entries, info/index.json extracts, and Hash("sha256") returns 41db0180… matching the repodata digest.

Closes #24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support for v2 conda packages (.conda) by treating them as an outer ZIP that contains pkg-*.tar.zst and info-*.tar.zst, and exposing a merged “tar-like” view via the existing tarReader APIs.

Changes:

  • Add a new .conda reader that opens relevant .tar.zst members and merges their tar entries into a single browse/extract view.
  • Register .conda in format detection/opening paths and document support in the README.
  • Add unit tests covering listing/extracting, hashing the outer archive, and decompression-limit behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
README.md Documents .conda as a supported archive type and describes how it’s presented.
conda.go Implements the .conda reader and member parsing/merging logic.
conda_test.go Adds tests for .conda open/list/extract/hash and size-limit behavior.
archives.go Registers the new conda format in detection and dispatch.
archives_test.go Extends TestDetectFormat to include .conda.
Suppressed comments (2)

conda.go:51

  • if files == nil treats an archive with matching members but zero tar entries as if the members were missing, and produces a misleading error. Track whether any pkg-/info- .tar.zst members were found instead of relying on whether any entries were appended.
	if files == nil {
		return nil, fmt.Errorf("no pkg-*.tar.zst or info-*.tar.zst member in conda package")
	}

conda.go:57

  • The merged view can contain duplicate paths (e.g., both tarballs containing the same directory entry). index keeps only the first occurrence for Extract, but List/ListDir will still surface duplicates from files, which is inconsistent for callers. Consider de-duplicating files by path while building index.
	index := make(map[string]int, len(files))
	for i, f := range files {
		if _, seen := index[f.info.Path]; !seen {
			index[f.info.Path] = i
		}

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread conda.go
Base automatically changed from zstd to main August 16, 2026 21:36
@andrew
andrew force-pushed the conda branch 2 times, most recently from 642a1d3 to 0588435 Compare August 16, 2026 21:46
The v2 conda format is an uncompressed zip containing metadata.json,
pkg-<name>.tar.zst and info-<name>.tar.zst. Both inner tarballs already
store their entries with the paths that appear in the equivalent v1
.tar.bz2 package (info/ is a prefix inside the tar), so the reader opens
each .tar.zst member through openTar and concatenates the entries into a
single tar view. Hash covers the outer .conda bytes, matching what
anaconda.org publishes in repodata.json.

Decompressed size is capped cumulatively across all members so a zip
with many pkg-*/info-* entries cannot exceed maxDecompressedSize by
staying under it per member.

Closes #24
@andrew
andrew merged commit 0425692 into main Aug 16, 2026
5 checks passed
@andrew
andrew deleted the conda branch August 16, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support .conda packages

2 participants