Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#910 Can not update intellij on linux #1101

Merged
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down