diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index c5668e51f..a4a323f88 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE Release with new features and bugfixes: +* https://github.com/devonfw/IDEasy/issues/910[#910]: Cannot update Intellij on Linux - FileAlreadyExistsException * https://github.com/devonfw/IDEasy/issues/38[#38]: Implement ToolCommandlet for Python The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/23?closed=1[milestone 2025.03.001]. diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/UpgradeSettingsCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/UpgradeSettingsCommandlet.java index 1a5b366bb..930dedc1b 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/UpgradeSettingsCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/UpgradeSettingsCommandlet.java @@ -1,5 +1,6 @@ package com.devonfw.tools.ide.commandlet; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.function.Function; @@ -59,7 +60,7 @@ private void updateLegacyFolder(Path folder, String legacyName, String newName) Path newFolder = folder.resolve(newName); if (fileAccess.isExpectedFolder(legacyFolder)) { try { - if (!fileAccess.exists(newFolder)) { + if (!Files.exists(newFolder)) { fileAccess.move(legacyFolder, newFolder, StandardCopyOption.REPLACE_EXISTING); this.context.success("Successfully renamed folder '{}' to '{}' in {}.", legacyName, newName, folder); } @@ -106,9 +107,8 @@ private void updateProperties() { } environmentVariables = environmentVariables.getParent(); } - FileAccess fileAccess = this.context.getFileAccess(); Path templatePropertiesDir = this.context.getSettingsTemplatePath().resolve(IdeContext.FOLDER_CONF); - if (fileAccess.exists(templatePropertiesDir)) { + if (Files.exists(templatePropertiesDir)) { EnvironmentVariablesPropertiesFile environmentVariablesProperties = new EnvironmentVariablesPropertiesFile(null, EnvironmentVariablesType.CONF, templatePropertiesDir, null, this.context); updateProperties(environmentVariablesProperties); diff --git a/cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java b/cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java index 94b8c305b..8e0d4d4fc 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java +++ b/cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java @@ -44,12 +44,6 @@ public interface FileAccess { */ boolean isFile(Path file); - /** - * @param file the {@link Path} to check. - * @return {@code true} if the given {@code file} points to an existing file, {@code false} otherwise (the given {@link Path} does not exist - */ - boolean exists(Path file); - /** * @param folder the {@link Path} to check. * @return {@code true} if the given {@code folder} points to an existing directory, {@code false} otherwise (a warning is logged in this case). diff --git a/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java b/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java index 16214d248..dae5669db 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java +++ b/cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java @@ -220,11 +220,6 @@ public boolean isFile(Path file) { return true; } - @Override - public boolean exists(Path file) { - return Files.exists(file); - } - @Override public boolean isExpectedFolder(Path folder) { @@ -781,7 +776,7 @@ public void extractPkg(Path file, Path targetDir) { @Override public void delete(Path path) { - if (!Files.exists(path)) { + if (!Files.exists(path, LinkOption.NOFOLLOW_LINKS)) { this.context.trace("Deleting {} skipped as the path does not exist.", path); return; } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java index cbf161436..8c22ba743 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/LocalToolCommandlet.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.nio.file.Files; +import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.Collection; @@ -88,7 +89,7 @@ public boolean install(boolean silent, EnvironmentContext environmentContext) { // we need to link the version or update the link. Path toolPath = getToolPath(); FileAccess fileAccess = this.context.getFileAccess(); - if (Files.exists(toolPath)) { + if (Files.exists(toolPath, LinkOption.NOFOLLOW_LINKS)) { fileAccess.backup(toolPath); } fileAccess.mkdirs(toolPath.getParent());