From 088fd8557252aa76913868004e85fcaa22142d26 Mon Sep 17 00:00:00 2001 From: Marcus van Elst Date: Tue, 21 Apr 2026 20:34:01 +0200 Subject: [PATCH] =?UTF-8?q?Anpassung=20der=20Testf=C3=A4lle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../validation/StartConfigurationValidator.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/bootstrap/validation/StartConfigurationValidator.java b/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/bootstrap/validation/StartConfigurationValidator.java index 89ed664..45a8178 100644 --- a/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/bootstrap/validation/StartConfigurationValidator.java +++ b/pdf-umbenenner-adapter-out/src/main/java/de/gecheckt/pdf/umbenenner/adapter/out/bootstrap/validation/StartConfigurationValidator.java @@ -350,6 +350,12 @@ public class StartConfigurationValidator { * This satisfies the "present or technically creatable" requirement: the folder need not * exist before the application starts, but must be reachable at startup time. *

+ * The write-access check is performed by creating and immediately deleting a temporary + * probe file inside the target folder. A pure {@code Files.isWritable} check is not used + * because it is known to return false negatives on mapped SMB network drives under + * Windows (ACL information as seen by the client can deny writes even when the actual + * write succeeds). The probe reflects the real ability to create files in the target. + *

* This separation allows unit tests to inject alternative implementations * that control the outcome of write-access or creation checks without relying on actual * filesystem permissions (which are platform-dependent). @@ -368,7 +374,14 @@ public class StartConfigurationValidator { if (!Files.isDirectory(path)) { return "- target.folder: path is not a directory: " + path; } - if (!Files.isWritable(path)) { + try { + Path probe = Files.createTempFile(path, ".writetest-", ".tmp"); + try { + Files.deleteIfExists(probe); + } catch (IOException cleanupFailure) { + LOG.debug("Could not delete write-probe file {}: {}", probe, cleanupFailure.toString()); + } + } catch (IOException e) { return "- target.folder: directory is not writable: " + path; } return null; // All checks passed