#797: zip symlink pure java#1995
Conversation
Coverage Report for CI Build 26784560341Coverage decreased (-0.02%) to 71.074%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions198 previously-covered lines in 2 files lost coverage.
Coverage Stats💛 - Coveralls |
…m/shodiBoy1/IDEasy into feature/797-zip-symlink-pure-java
Release includes new features and bug fixes for IDEasy.
hohwille
left a comment
There was a problem hiding this comment.
@shodiBoy1 thanks for your PR and your analysis of the root cause. I like that you always take such special problem and analyse it properly trying to come up with a rather small fixing PR👍
Surely we could merge this as is as a quickfix.
However, you revealed here that we have actually implemented our link function wrong (and therefore our "unpack" functions - not only for zip but also for tar).
IMHO your PR is not fixing that bug but adding a workaround with quite some redundancies.
My goal is that we aim for true quality so I would love to fix the link function properly.
Can you maybe extract a JUnit test that reproduces the scenario with invoking our link function?
BTW: We meanwhile also have ide ln -s <source> <link> to test such things. If you want to test with relative being true you can do ide ln -s -r <source> <link>.
If that is buggy, please lets fix the root cause.
|
|
||
| final List<PathLink> links = new ArrayList<>(); | ||
| // link path -> raw target string from the archive; LinkedHashMap keeps entry order for deterministic creation | ||
| final Map<Path, String> symlinks = new LinkedHashMap<>(); |
There was a problem hiding this comment.
what is wrong with PathLink object?
I am not getting why you decided not to use it anymore?
IMHO it is still containing the same information in a slightly more structured way.
| // for a symlink entry the file content IS the link target string (Unix zip convention) | ||
| String linkTarget = IOUtils.toString(entryStream, StandardCharsets.UTF_8); | ||
| Path parent = entryPath.getParent(); | ||
| Path source = parent.resolve(linkTarget).normalize(); | ||
| resolveRelativePathSecure(source, root, linkTarget); | ||
| links.add(new PathLink(source, entryPath, PathLinkType.SYMBOLIC_LINK)); | ||
| mkdirs(parent); | ||
| // security: refuse archives whose link would resolve outside the extraction root | ||
| resolveRelativePathSecure(entryPath.getParent().resolve(linkTarget).normalize(), root, linkTarget); | ||
| mkdirs(entryPath.getParent()); | ||
| symlinks.put(entryPath, linkTarget); |
There was a problem hiding this comment.
Still I cannot see a reason for this change. Still the same thing is happening here.
| Path linkPath = link.getKey(); | ||
| String rawTarget = link.getValue(); | ||
| Files.deleteIfExists(linkPath); | ||
| try { | ||
| Files.createSymbolicLink(linkPath, Path.of(rawTarget)); | ||
| } catch (FileSystemException e) { | ||
| // on Windows without symlink permission fall back to a junction, same as link() does | ||
| if (SystemInfoImpl.INSTANCE.isWindows()) { | ||
| Path absoluteSource = linkPath.getParent().resolve(rawTarget).normalize(); | ||
| mklinkOnWindows(Path.of(rawTarget), absoluteSource, linkPath, PathLinkType.SYMBOLIC_LINK, true); | ||
| } else { | ||
| throw e; | ||
| } | ||
| } |
There was a problem hiding this comment.
you are slightly reimplementing our link function here.
Could the entire fix instead be to simply change true to false here, what would also fix the same bug in "untar" (that we might not yet have discovered)?
IDEasy/cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java
Lines 140 to 142 in 6080ee7
There was a problem hiding this comment.
OK, seems that there is another "bug" in our link implementation:
IDEasy/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java
Lines 528 to 530 in 6080ee7
This was introduced in commit 083a35d.
My goal is still to get our link and "unpack" methods finally fixed.
IMHO that change was wrong.
There was a problem hiding this comment.
if relative is false, then why should our link function fiddle around with any of the given Path values at all?
IMHO this is all wrong. Maybe it is needed by the fallback for mklink but then it should be done only there if required.
This PR fixes #797: fix VSCode install on macOS
Implemented changes:
Testing instructions
Check out the PR:
gh pr checkout 1995
Run on a Mac:
Checklist for this PR
mvn clean testlocally all tests pass and build is successful#«issue-id»: «brief summary»(e.g.#921: fixed setup.bat). If no issue ID exists, title only.In Progressand assigned to you or there is no issue (might happen for very small PRs)with
internal