Skip to content

#1884 keep symlinks while unzipping#1924

Open
satorus wants to merge 4 commits into
devonfw:mainfrom
satorus:feature/1884-keep-symlinks-while-unzipping
Open

#1884 keep symlinks while unzipping#1924
satorus wants to merge 4 commits into
devonfw:mainfrom
satorus:feature/1884-keep-symlinks-while-unzipping

Conversation

@satorus
Copy link
Copy Markdown
Contributor

@satorus satorus commented May 12, 2026

This PR fixes #1884

Implemented changes:

  • Rewrote extractZipWithJava to use ZipFile instead of Java FileSystem. This allows to read symlinks while also allowing to get the POSIX file permissions using File Attributes and Bit-Operations.
  • Two-phase symlink extraction: symlink entries are collected during extraction and created only after all regular files are written, matching the existing TAR behaviour.
  • Removed extractZipWithSystemUnzip: the Mac-specific workaround that used /usr/bin/unzip is gone. The Java implementation now handles all platforms uniformly.
  • Added getZipUnixMode and isZipSymlink helpers: isolate the bit-shifting logic for reading Unix file-type bits from ZIP external attributes, with full Javadoc explaining the bit layout.
  • Preserved file permissions via onFileCopiedFromZip using PathPermissions.of(unixMode).toPosix(), skipped on Windows.
  • 6 ZIP test resources added covering: basic symlink, reversed entry order, no Unix attributes (Windows ZIP), symlink + executable, symlink to directory, symlink with ../ relative target.
  • 12 new test cases in FileAccessImplTest covering: symlink preservation, file permissions, reversed entry order (validates two-phase approach), Windows-created ZIPs, combinations, directory symlinks, relative-parent symlinks, and OS-simulated permission behaviour (Mac and Windows mocks).

How to test:

Difficult. One test is to download and install Terraform and then running terraform --version. This shows that at least the file permissiosn still work. See: #835

For manually checking the unzipping, one can add (@TempDir(cleanup = CleanupMode.NEVER) Path tempDir) to the new test cases. This will create the ideasy-unzipped files in the /tmp/junit-... directories, where one can manually check the unzipped files for correct file permissions and existing symlinks.


Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal

Checklist for tool commandlets

Have you added a new «tool» as commandlet? There are the following additional checks:

  • The tool can be installed automatically (during setup via settings) or via the commandlet call
  • The tool is isolated in its IDEasy project, see Sandbox Principle
  • The new tool is added to the table of tools in LICENSE.asciidoc
  • The new commandlet is a command-wrapper for «tool»
  • Proper help texts for all supported languages are added here
  • The new commandlet installs potential dependencies automatically
  • The variables «TOOL»_VERSION and «TOOL»_EDITION are honored by your commandlet
  • The new commandlet is tested on all platforms it is available for or tested on all platforms that are in scope of the linked issue

satorus added 3 commits May 12, 2026 09:20
…mlinks and keep existing symlinks in place
…missions + symlinks and for simulated mac and windows to check the isWindows() guard
@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board May 12, 2026
@satorus satorus added enhancement New feature or request unpack logic to unpack archives (tar, zip, tgz, zbz2, msi, dmg, etc.) labels May 12, 2026
@satorus satorus moved this from 🆕 New to Team Review in IDEasy board May 12, 2026
@satorus satorus marked this pull request as ready for review May 12, 2026 08:44
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 12, 2026

Coverage Report for CI Build 25723559954

Coverage increased (+0.04%) to 70.659%

Details

  • Coverage increased (+0.04%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 192 coverage regressions across 2 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

192 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/io/FileAccessImpl.java 191 67.09%
com/devonfw/tools/ide/io/FileCopyMode.java 1 79.31%

Coverage Stats

Coverage Status
Relevant Lines: 15466
Covered Lines: 11394
Line Coverage: 73.67%
Relevant Branches: 6916
Covered Branches: 4421
Branch Coverage: 63.92%
Branches in Coverage %: Yes
Coverage Strength: 3.12 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request unpack logic to unpack archives (tar, zip, tgz, zbz2, msi, dmg, etc.)

Projects

Status: Team Review

Development

Successfully merging this pull request may close these issues.

Implement proper ZIP extraction

3 participants