diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/FTPClient.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/FTPClient.java index a44f6900f..69f712159 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/FTPClient.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/FTPClient.java @@ -36,7 +36,11 @@ public class FTPClient { protected FTPClient(String server, int port, String path, String user, String password) { this.server = server; this.port = port; - this.path = path; + if (path.endsWith("/")) { + this.path = path; + } else { + this.path = path + "/"; + } this.user = user; this.password = password; @@ -77,7 +81,7 @@ public class FTPClient { } private String resolveRemotePath(String path) { - return String.join("/", this.path, path); + return String.join("", this.path, path); } /** diff --git a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/FTPClientTest.java b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/FTPClientTest.java index 7e2d97256..a8bba306b 100644 --- a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/FTPClientTest.java +++ b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/FTPClientTest.java @@ -130,6 +130,25 @@ public class FTPClientTest implements ResourceLoaderTests { return client; } + @Test + public void testDelete2() throws IOException { + + FTPClient client = connectToFTPClient2(); + + String deleteFilePath = dummyFileToDeletePath.toFile().getAbsolutePath(); + assertTrue(fakeFtpServer.getFileSystem().exists(deleteFilePath)); + + client.delete( RELATIVE_PATH_2 + "/" + DUMMY_FILE_TO_DELETE); + assertFalse(fakeFtpServer.getFileSystem().exists(deleteFilePath)); + } + + @NotNull + private static FTPClient connectToFTPClient2() throws IOException { + FTPClient client = new FTPClient("localhost", FAKE_FTP_PORT, RELATIVE_PATH_1, DUMMY_USER, DUMMY_PASSWORD); + client.connect(); + return client; + } + @Test public void testUpload() throws IOException {