Fixed synchroniser deleting source directory
All checks were successful
ci/woodpecker/manual/test Pipeline was successful
ci/woodpecker/manual/package Pipeline was successful

This commit is contained in:
Harrison Deng 2024-11-12 06:59:36 +00:00
parent ab9f4b0525
commit 11e3ca739b
3 changed files with 11 additions and 6 deletions

5
.woodpecker/package.yml Normal file
View File

@ -0,0 +1,5 @@
steps:
- name: package
image: maven:3.9.9-eclipse-temurin-21-alpine
commands:
- mvn package

5
.woodpecker/test.yml Normal file
View File

@ -0,0 +1,5 @@
steps:
- name: test
image: maven:3.9.9-eclipse-temurin-21-alpine
commands:
- mvn test

View File

@ -15,16 +15,11 @@ public class ApacheCommonsIOSynchroniser implements Synchroniser {
source = Path.of(root.getPath(), dest.getPath()).toFile(); 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 (source.isDirectory()) {
if (dest.isDirectory()) { if (dest.isDirectory()) {
FileUtils.copyDirectory(source, dest); FileUtils.copyDirectory(source, dest);
} else { } 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. // TODO add more detail to error message.
} }
} else { } else {