mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
## Summary - Adds new `Bun.Archive` API for working with tar archives - `Bun.Archive.from(data)` - Create archive from object, Blob, TypedArray, or ArrayBuffer - `Bun.Archive.write(path, data, compress?)` - Write archive to disk (async) - `archive.extract(path)` - Extract to directory, returns `Promise<number>` (file count) - `archive.blob(compress?)` - Get archive as Blob (async) - `archive.bytes(compress?)` - Get archive as Uint8Array (async) Key implementation details: - Uses existing libarchive bindings for tarball creation/extraction via `extractToDisk` - Uses libdeflate for gzip compression - Immediate byte copying for GC safety (no JSValue protection, no `hasPendingActivity`) - Async operations run on worker pool threads with proper VM reference handling - Growing memory buffer via `archive_write_open2` callbacks for efficient tarball creation ## Test plan - [x] 65 comprehensive tests covering: - Normal operations (create, extract, blob, bytes, write) - GC safety (unreferenced archives, mutation isolation) - Error handling (invalid args, corrupted data, I/O errors) - Edge cases (large files, many files, special characters, path normalization) - Concurrent operations 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>