From 11e3ca739b4576f0b6f370649ba082133879fa83 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Tue, 12 Nov 2024 06:59:36 +0000 Subject: [PATCH] Fixed synchroniser deleting source directory --- .woodpecker/package.yml | 5 +++++ .woodpecker/test.yml | 5 +++++ .../synchronisation/ApacheCommonsIOSynchroniser.java | 7 +------ 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .woodpecker/package.yml create mode 100644 .woodpecker/test.yml diff --git a/.woodpecker/package.yml b/.woodpecker/package.yml new file mode 100644 index 0000000..a9983cf --- /dev/null +++ b/.woodpecker/package.yml @@ -0,0 +1,5 @@ +steps: + - name: package + image: maven:3.9.9-eclipse-temurin-21-alpine + commands: + - mvn package \ No newline at end of file diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml new file mode 100644 index 0000000..ef321e8 --- /dev/null +++ b/.woodpecker/test.yml @@ -0,0 +1,5 @@ +steps: + - name: test + image: maven:3.9.9-eclipse-temurin-21-alpine + commands: + - mvn test \ No newline at end of file diff --git a/src/main/java/solutions/reslate/entertainment/spigotresourcesync/synchronisation/ApacheCommonsIOSynchroniser.java b/src/main/java/solutions/reslate/entertainment/spigotresourcesync/synchronisation/ApacheCommonsIOSynchroniser.java index 686a007..87af492 100644 --- a/src/main/java/solutions/reslate/entertainment/spigotresourcesync/synchronisation/ApacheCommonsIOSynchroniser.java +++ b/src/main/java/solutions/reslate/entertainment/spigotresourcesync/synchronisation/ApacheCommonsIOSynchroniser.java @@ -15,16 +15,11 @@ public class ApacheCommonsIOSynchroniser implements Synchroniser { source = Path.of(root.getPath(), dest.getPath()).toFile(); } - if (source.exists() && dest.exists()) { - dest.delete(); - // Fixes an issue where sometimes, Apache Commons IO will fail to overwrite. - } - if (source.isDirectory()) { if (dest.isDirectory()) { FileUtils.copyDirectory(source, dest); } else { - throw new IOException("Cannot synchronise directy to non-directory!"); + throw new IOException("Cannot synchronise directory to non-directory!"); // TODO add more detail to error message. } } else {