Repository navigation
#2466: remove broken software links on uninstall - #2496
HadiDawoud wants to merge 5 commits into
Conversation
bdd7ea6 to
3b2f22c
Compare
Coverage Report for CI Build 38900708598Coverage increased (+0.03%) to 74.789%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions6 previously-covered lines in 3 files lost coverage.
Coverage Stats💛 - Coveralls |
|
Thanks @HadiDawoud, nice fix. Tested this on Mac and Windows. Unit tests: UninstallCommandletTest - 11/11 passed. Manual: installed gradle, deleted $IDE_ROOT/_ide/software/default/gradle so software/gradle became a broken link, then ran uninstall from this branch. Got Successfully uninstalled gradle and the link was gone. Same on Windows (Explorer showed “location is not available” before uninstall, folder gone after). Looks good to me, the original issue is fixed. |
hohwille
left a comment
There was a problem hiding this comment.
@HadiDawoud thanks for your PR and fixing the problem. 👍
You found the right spots and tricks (NOFOLLOW_LINKS) to fix it.
I would suggest fixing the bug as its root avoiding redundant knowledge and implementation details about uninstalling tools outside the uninstall routine.
Then we can merge.
| if (toolCommandlet.isInstalled()) { | ||
| toolCommandlet.uninstall(); | ||
| } else { | ||
| LOG.warn("Couldn't uninstall " + toolCommandlet.getName() + " because we could not find an installation"); | ||
| removeSoftwareLeftover(toolCommandlet); | ||
| } |
There was a problem hiding this comment.
IMHO the bug is that we are using isInstalled() to see if the tool is correctly installed.
Actually the uninstall() method of [Local]ToolCommandlet should be able to uninstall a tool including such leftovers.
Therefore I would suggest to fix the bug in this method rather than keeping the bug as is and adding a fix outside as a workaround.
So my suggestion is to remove the if condition here and change this to just:
toolCommandlet.uninstall();
Then in the uninstall() method we should handle the warning logging that if I call uninstall on a tool that was never installed (not even broken leftover) to raise the warning.
| Path toolPath = getToolPath(); | ||
| if (!Files.exists(toolPath)) { | ||
| // Use NOFOLLOW_LINKS so a broken symlink/junction is still detected and deleted. | ||
| if (!Files.exists(toolPath, LinkOption.NOFOLLOW_LINKS)) { |
There was a problem hiding this comment.
So we already have that warning.
Excellent catch that you added the NOFOLLOW_LINKS option here! 👍
…overs of package-manager tools
Thanks for the review! I removed the isInstalled() check, so UninstallCommandlet now just calls uninstall(). The warning and the NOFOLLOW_LINKS fix are inside uninstall(). For pip-like tools the tool path points to the parent tool, so I added a small override that only cleans up the leftover software/pip folder (or warns) without touching the package manager. |
This PR fixes #2466
Implemented changes:
UninstallCommandletno longer checksisInstalled()and simply callstoolCommandlet.uninstall(), so the bug is fixed in the uninstall routine itselfuninstall()detects broken software symlinks withNOFOLLOW_LINKSand removes them; the "never installed" warning stays inuninstall()PackageManagerBasedLocalToolCommandlet.uninstall()removes leftoversoftware/«tool»folders (e.g. only.ide.software.version) or warns, without invoking the package managerTesting instructions
mvn -Dtest=UninstallCommandletTest testin theclifolder and verify all 12 tests passide install gradle, delete the version under$IDE_ROOT/_ide/software/default/gradle, thenide uninstall gradle- the broken link under$IDE_HOME/software/gradleshould be removed$IDE_HOME/software/pip/.ide.software.versionwithout a pip installation, thenide uninstall pip- the folder should be removedChecklist for this PR
Make sure everything is checked before merging this PR. For further info see
our DoD.
mvn clean testlocally all tests pass and build is successful#«issue-id»: «brief summary»(e.g.#921: fixed setup.batand notfeature/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
internalpom.xmlfiles or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc