Detect extensionless archive formats - #20
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Not ready to approve
Open now buffers the entire stream before it can reject unsupported inputs, increasing memory/IO cost for large non-archive readers.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Adds content-based archive format detection as a fallback when filename-based format detection fails, enabling Open/OpenBytes to handle extensionless inputs while keeping existing extension mappings primary.
Changes:
- Add
magic-based content sniffing fallback for ZIP/TAR/gzip/bzip2/xz when no supported filename extension is present. - Add tests/fixtures covering extensionless inputs, misleading known extensions, generic compressed streams, and extensionless gem content.
- Add a benchmark for the content-detected
tar.gzpath and document the fallback behavior in the README.
File summaries
| File | Description |
|---|---|
| README.md | Documents filename-first behavior and the content-sniffing fallback. |
| hash_test.go | Updates OpenBytes zero-copy test to exercise extensionless detection. |
| hash_bench_test.go | Adds benchmark for the detected tar.gz path via extensionless OpenBytes. |
| archives.go | Introduces content-based format detection fallback and format constants. |
| archives_test.go | Adds fixtures and tests for extensionless detection and precedence rules. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detect ZIP, TAR, gzip, bzip2, and xz content when a filename has no supported archive extension. Keep existing filename mappings primary, preserve
OpenByteszero-copy behavior, and route compressed content through the existing TAR readers.Add fixtures for both opening APIs, misleading known extensions, generic compressed streams, and extensionless gem content. Add a benchmark for the detected tar.gz path and document the fallback.