Skip to content

Add zst support to archiver library#663

Merged
aooohan merged 7 commits intomainfrom
copilot/fix-archiver-library-zst-support
May 2, 2026
Merged

Add zst support to archiver library#663
aooohan merged 7 commits intomainfrom
copilot/fix-archiver-library-zst-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 1, 2026

The Lua archiver library did not recognize or extract zstd-compressed tar archives. Plugins using archiver.decompress() could not handle SDK distributions packaged as .tar.zst or .tzst.

  • Archive support

    • Added .tar.zst and .tzst detection in the shared decompressor factory.
    • Added zstd tar extraction via github.com/klauspost/compress/zstd.
  • Extraction behavior

    • Preserves existing tar archive behavior by stripping a detected common root directory.
    • Supports flat archives without dropping path components.
    • Rejects path traversal entries before writing files.
  • Docs and coverage

    • Updated English and Chinese archiver library docs to list zst formats.
    • Added focused tests for format selection, extraction, common-root stripping, and traversal rejection.

Example plugin usage:

local archiver = require("vfox.archiver")
local err = archiver.decompress("node-v22.0.0-linux-x64.tar.zst", "install-dir")

@bytemain
Copy link
Copy Markdown
Member

bytemain commented May 1, 2026

@aooohan https://github.com/astral-sh/python-build-standalone 打包出来的 python 很多都是 .tar.zst 格式的,目前 vfox 还不支持。

   },
    {
      "implementation": "cpython",
      "version": "3.10.20",
      "display_version": "3.10.20",
      "variant": "default",
      "release": "20260414",
      "filename": "cpython-3.10.20+20260414-aarch64-unknown-linux-gnu-pgo+lto-full.tar.zst",
      "url": "https://github.com/astral-sh/python-build-standalone/releases/download/20260414/cpython-3.10.20%2B20260414-aarch64-unknown-linux-gnu-pgo%2Blto-full.tar.zst",
      "platform": {
        "os": "linux",
        "arch": "aarch64",
        "libc": "gnu"
      },
      "asset": {
        "size": 66062262,
        "content_type": "application/octet-stream",
        "created_at": "2026-04-14T17:26:12Z",
        "updated_at": "2026-04-14T17:26:15Z",
        "sha256": "cbd9d1d45cabb7268b628075f58e8b2cc7de47b95834daa2f1e73a0645bf2d0e"
      }
    }
  ]
}

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 50.98039% with 50 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.62%. Comparing base (8182390) to head (daa537a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/shared/util/decompressor.go 50.98% 33 Missing and 17 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #663      +/-   ##
==========================================
+ Coverage   25.17%   25.62%   +0.45%     
==========================================
  Files          83       83              
  Lines        5693     5795     +102     
==========================================
+ Hits         1433     1485      +52     
- Misses       4082     4115      +33     
- Partials      178      195      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bytemain bytemain marked this pull request as ready for review May 1, 2026 14:20
Copilot AI review requested due to automatic review settings May 1, 2026 14:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds .tar.zst / .tzst (zstd-compressed tar) support to the shared Lua archiver decompression pipeline so plugins can decompress SDK distributions packaged with zstd.

Changes:

  • Introduces a new ZstdTarDecompressor using github.com/klauspost/compress/zstd and wires it into NewDecompressor() via .tar.zst / .tzst suffix detection.
  • Adds tests covering decompressor selection, extraction, common-root stripping, and traversal rejection.
  • Updates English + Simplified Chinese archiver docs to list zstd formats and updates go.mod to include the zstd dependency as a direct requirement.

Reviewed changes

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

Show a summary per file
File Description
internal/shared/util/decompressor.go Adds zstd-tar decompressor implementation + file suffix detection.
internal/shared/util/decompressor_test.go Adds tests + helper to generate .tar.zst fixtures.
go.mod Promotes github.com/klauspost/compress to a direct dependency.
docs/plugins/library/archiver.md Documents .tar.zst / .tzst support (EN).
docs/zh-hans/plugins/library/archiver.md Documents .tar.zst / .tzst support (ZH-Hans).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/shared/util/decompressor.go
Comment thread internal/shared/util/decompressor.go
Comment thread internal/shared/util/decompressor.go
Comment thread internal/shared/util/decompressor_test.go
Comment thread docs/zh-hans/plugins/library/archiver.md Outdated
@aooohan aooohan merged commit f63a6d1 into main May 2, 2026
8 checks passed
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.

4 participants