Skip to content

Support streaming TAR hard-link extraction and opt-in preservation - #493

Open
wilx wants to merge 2 commits into
codehaus-plexus:masterfrom
wilx:hardlinks-v2
Open

wilx wants to merge 2 commits into
codehaus-plexus:masterfrom
wilx:hardlinks-v2

Conversation

@wilx

@wilx wilx commented Sep 13, 2026

Copy link
Copy Markdown

What does this change?

Adds streaming TAR hard-link extraction, opt-in preservation, and logical content access through archived file sets.

  • Extraction: ordinary extraction uses one forward stream, without a preliminary scan or payload staging. Links must reference earlier regular members or backward-link chains and use the target's current mapped destination, following GNU tar and bsdtar. Invalid links fail without a copy fallback.
  • Creation: TarArchiver.setPreserveHardLinks(true) preserves resources with equal identities and compatible output metadata. The default is false; transformed contents, unknown identities, and conflicting metadata produce full entries. Resource subclasses must explicitly guarantee their content identity.
  • Resource access: aliases expose their referenced contents, supporting alias-only selection, TAR repacking, and ZIP conversion. Earlier payload reads may replay decompression and cache requested contents.

Related issue

Addresses PR #286 using explicit resource identities, mapped destination handling, and logical resource reads, while retaining the protected AbstractUnArchiver.extractFile signature.

Depends on Plexus IO PR #191. Local builds require installing its 3.7.1-SNAPSHOT first, then building Archiver with JDK 17+. The dependency must be available to CI and its version finalized before merging.

Anything reviewers should look at closely?

  • Contained directory-symlink traversal is allowed by default, as in GNU tar. TarUnArchiver.setFailOnSymlinkTraversal(true) rejects intermediate symlinks in destinations and hard-link targets. Both settings enforce destination containment; failures can leave earlier outputs in place.
  • Directly managed TAR readers and resource collections require closure. Archivers close registered collections and their payload caches on success or failure. Concurrent reads on one reader are unsupported.

Documentation covers detailed semantics, GNU tar/bsdtar differences, replay/cache tradeoffs, and Maven Assembly configuration.

Validation

  • JDK 17 build, Javadoc, and formatting: 651 tests, zero failures/errors, four skips, including 147 hard-link/streaming/policy invocations across six compression modes.
  • Compatibility fixtures checked with GNU tar 1.35 and bsdtar 3.7.2.
  • Maven Assembly 3.8.0 produces a data member and backward hard link; both utilities verify contents and a shared inode.

Validation is Linux-only; Windows and macOS remain unvalidated.

@wilx wilx changed the title Support TAR hard-link extraction and opt-in preservation Support streaming TAR hard-link extraction and opt-in preservation Sep 13, 2026
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.

1 participant