From 7659d16d8e943eec983ea0b473046b1aaf4c5982 Mon Sep 17 00:00:00 2001 From: Aqua-sc <108478185+Aqua-sc@users.noreply.github.com> Date: Fri, 8 Mar 2024 18:14:40 +0100 Subject: [PATCH] method for testpath --- .../src/main/java/com/ugent/pidgeon/util/Filehandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java b/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java index 8b20db3a..1ae67c08 100644 --- a/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java +++ b/backend/app/src/main/java/com/ugent/pidgeon/util/Filehandler.java @@ -61,6 +61,10 @@ static public Path getSubmissionPath(long projectid, long groupid, long submissi return Path.of(BASEPATH,"projects", String.valueOf(projectid), String.valueOf(groupid), String.valueOf(submissionid)); } + static public Path getTestPath(long projectid) { + return Path.of(BASEPATH,"projects", String.valueOf(projectid), "tests"); + } + public static boolean isZipFile(File file) throws IOException { // Create a Tika instance Tika tika = new Tika(); @@ -86,7 +90,7 @@ public static Path saveTest(MultipartFile file, long projectId) throws IOExcepti } // Create directory if it doesn't exist - Path projectDirectory = Paths.get("/data/projects/" + projectId + "/tests/"); + Path projectDirectory = getTestPath(projectId); if (!Files.exists(projectDirectory)) { Files.createDirectories(projectDirectory); }