From 18fbbd3b41eed6e76890cbd04e7c5671960b0073 Mon Sep 17 00:00:00 2001 From: mamunozgil <miguel.munoz-gil@hft-stuttgart.de> Date: Wed, 15 Jan 2025 11:51:28 +0100 Subject: [PATCH] Overrwrite and debug added --- .../dtabackend/utils/ExecuteTestUtil.java | 6 +++ .../dtabackend/utils/FileUtil.java | 38 +++++++++---------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/main/java/de/hftstuttgart/dtabackend/utils/ExecuteTestUtil.java b/src/main/java/de/hftstuttgart/dtabackend/utils/ExecuteTestUtil.java index e8f1dc2..99298b6 100644 --- a/src/main/java/de/hftstuttgart/dtabackend/utils/ExecuteTestUtil.java +++ b/src/main/java/de/hftstuttgart/dtabackend/utils/ExecuteTestUtil.java @@ -95,6 +95,12 @@ public class ExecuteTestUtil { image = config.group(5); } + // Log the paths before binding + LOG.debug("Binding paths for Docker container:"); + LOG.debug("Test Path: {}", testPath); + LOG.debug("Source Path: {}", srcPath); + LOG.debug("Result Path: {}", resultPath); + // Start the test-container with professor-given image and submission-specific volume mounts dockerUtil.runContainerWithBinds( image, diff --git a/src/main/java/de/hftstuttgart/dtabackend/utils/FileUtil.java b/src/main/java/de/hftstuttgart/dtabackend/utils/FileUtil.java index 33404e3..24a7892 100644 --- a/src/main/java/de/hftstuttgart/dtabackend/utils/FileUtil.java +++ b/src/main/java/de/hftstuttgart/dtabackend/utils/FileUtil.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,23 +43,22 @@ public class FileUtil { } } - /** - * Copy the folder and its contents. - * @param src Source folder path - * @param dst Destination folder path - * @throws IOException if an I/O error occurs - */ - public static void copyFolder(Path src, Path dst) throws IOException { - Files.walk(src) - .forEach(source -> { - try { - Path destination = dst.resolve(src.relativize(source)); - Files.copy(source, destination); - LOG.debug("Copying file from: {} to {}", source, destination); - } catch (IOException e) { - LOG.debug("Error copying file from: {} to {}", source, dst.resolve(src.relativize(source)), e); - throw new RuntimeException(e.getMessage(), e); - } - }); - } +/** + * Copy the folder and its contents, overwriting existing files if they exist. + * @param src Source folder path + * @param dst Destination folder path + * @throws IOException if an I/O error occurs + */ +public static void copyFolder(Path src, Path dst) throws IOException { + Files.walk(src).forEach(source -> { + try { + Path destination = dst.resolve(src.relativize(source)); + Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING); + LOG.debug("Successfully copied file from: {} to {}", source, destination); + } catch (IOException e) { + LOG.error("Error copying file from: {} to {}", source, dst.resolve(src.relativize(source)), e); + throw new RuntimeException(e.getMessage(), e); + } + }); +} } -- GitLab