Fix #4481: 修复 .hmcl 目录为跨驱动器符号链接时无法卸载 Java 的问题 (#4492)

This commit is contained in:
Glavo 2025-09-16 19:46:59 +08:00 committed by GitHub
parent 5a8d567bd7
commit b328ed2cc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -209,9 +209,18 @@ public final class JavaManager {
public static Task<Void> getUninstallJavaTask(JavaRuntime java) {
assert java.isManaged();
Path root = REPOSITORY.getPlatformRoot(java.getPlatform());
Path relativized = root.relativize(java.getBinary());
Path platformRoot;
try {
platformRoot = REPOSITORY.getPlatformRoot(java.getPlatform()).toRealPath();
} catch (Throwable ignored) {
return Task.completed(null);
}
if (!java.getBinary().startsWith(platformRoot))
return Task.completed(null);
Path relativized = platformRoot.relativize(java.getBinary());
if (relativized.getNameCount() > 1) {
FXUtils.runInFX(() -> {
try {