diff --git a/base/src/main/kotlin/de/staropensource/engine/base/utility/FileAccess.kt b/base/src/main/kotlin/de/staropensource/engine/base/utility/FileAccess.kt index 5ad6fd6..7eb716a 100644 --- a/base/src/main/kotlin/de/staropensource/engine/base/utility/FileAccess.kt +++ b/base/src/main/kotlin/de/staropensource/engine/base/utility/FileAccess.kt @@ -690,6 +690,13 @@ class FileAccess { * If nothing exists at this location, * then nothing will be done. * + * If a symbolic link exists at this + * location, then the just symbolic link + * will be deleted, not the file or + * directory it's pointing to. To delete + * the target too, use [getLinkDestination] + * before calling this method. + * * @return this instance * @throws IOAccessException on IO error * @since v1-alpha10 @@ -700,10 +707,11 @@ class FileAccess { try { logger.diag("Deleting '${unformatFromPath(path)}'") - if (file.isDirectory) + if (!isSymbolicLink() && file.isDirectory) Files.walkFileTree(path, DeleteDirectoryVisitor(path)) Files.delete(path) + } catch (_: NoSuchFileException) { } catch (exception: Exception) { throw IOAccessException("Unable to delete '${unformatFromPath(path)}'", exception) }