diff --git a/core/src/main/java/io/kestra/core/storages/InternalNamespace.java b/core/src/main/java/io/kestra/core/storages/InternalNamespace.java index 7ff43f9338b..9b1921027fa 100644 --- a/core/src/main/java/io/kestra/core/storages/InternalNamespace.java +++ b/core/src/main/java/io/kestra/core/storages/InternalNamespace.java @@ -201,6 +201,6 @@ public URI createDirectory(Path path) throws IOException { **/ @Override public boolean delete(Path path) throws IOException { - return storage.delete(tenant, NamespaceFile.of(namespace, path).storagePath().toUri()); + return storage.delete(tenant, URI.create(path.toString().replace("\\","/"))); } } diff --git a/core/src/main/java/io/kestra/core/utils/WindowsUtils.java b/core/src/main/java/io/kestra/core/utils/WindowsUtils.java index a2cd03f1107..45b9ca4deec 100644 --- a/core/src/main/java/io/kestra/core/utils/WindowsUtils.java +++ b/core/src/main/java/io/kestra/core/utils/WindowsUtils.java @@ -5,20 +5,26 @@ public class WindowsUtils { - public static String windowsToUnixPath(String path){ + public static String windowsToUnixPath(String path, boolean startWithSlash) { Matcher matcher = java.util.regex.Pattern.compile("([A-Za-z]:)").matcher(path); String unixPath = matcher.replaceAll(m -> m.group().toLowerCase()); unixPath = unixPath .replace("\\", "/") .replace(":", ""); - if (!unixPath.startsWith("/")) { + if (!unixPath.startsWith("/") && startWithSlash) { unixPath = "/" + unixPath; } return unixPath; } + public static String windowsToUnixPath(String path) { + return windowsToUnixPath(path, true); + } + public static URI windowsToUnixURI(URI uri) { - return URI.create(windowsToUnixPath(uri.toString())); + + return URI.create(windowsToUnixPath(uri.toString(), false)); + } } diff --git a/core/src/main/java/io/kestra/plugin/core/namespace/DeleteFiles.java b/core/src/main/java/io/kestra/plugin/core/namespace/DeleteFiles.java index 3f008c5b8e1..1ed79b75596 100644 --- a/core/src/main/java/io/kestra/plugin/core/namespace/DeleteFiles.java +++ b/core/src/main/java/io/kestra/plugin/core/namespace/DeleteFiles.java @@ -20,6 +20,7 @@ import org.slf4j.Logger; import java.net.URI; +import java.nio.file.Path; import java.util.List; import java.util.Map; @@ -103,7 +104,7 @@ public Output run(RunContext runContext) throws Exception { long count = matched .stream() .map(Rethrow.throwFunction(file -> { - if (namespace.delete(file)) { + if (namespace.delete(NamespaceFile.of(renderedNamespace, Path.of(file.path().replace("\\","/"))).storagePath())) { logger.debug(String.format("Deleted %s", (file.path()))); return true; } diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/api/NamespaceFileController.java b/webserver/src/main/java/io/kestra/webserver/controllers/api/NamespaceFileController.java index 5cef81ae81f..7784a576e02 100644 --- a/webserver/src/main/java/io/kestra/webserver/controllers/api/NamespaceFileController.java +++ b/webserver/src/main/java/io/kestra/webserver/controllers/api/NamespaceFileController.java @@ -6,6 +6,7 @@ import io.kestra.core.storages.StorageInterface; import io.kestra.core.tenant.TenantService; import io.kestra.core.utils.Rethrow; +import io.kestra.core.utils.WindowsUtils; import io.micronaut.core.annotation.Nullable; import io.micronaut.http.HttpResponse; import io.micronaut.http.MediaType;