Skip to content

Detect extensionless archive formats - #20

Merged
andrew merged 2 commits into
mainfrom
magic-open-integration
Jul 31, 2026
Merged

Detect extensionless archive formats#20
andrew merged 2 commits into
mainfrom
magic-open-integration

Conversation

@andrew

@andrew andrew commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Detect ZIP, TAR, gzip, bzip2, and xz content when a filename has no supported archive extension. Keep existing filename mappings primary, preserve OpenBytes zero-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.

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.

🟡 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.gz path 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.

Comment thread archives.go
@andrew
andrew merged commit 3c460a4 into main Jul 31, 2026
5 checks passed
@andrew
andrew deleted the magic-open-integration branch July 31, 2026 15:04
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.

2 participants