diff --git a/src/main/java/org/carlspring/cloud/storage/s3fs/S3FileSystemProvider.java b/src/main/java/org/carlspring/cloud/storage/s3fs/S3FileSystemProvider.java index 219743e1..f9717068 100644 --- a/src/main/java/org/carlspring/cloud/storage/s3fs/S3FileSystemProvider.java +++ b/src/main/java/org/carlspring/cloud/storage/s3fs/S3FileSystemProvider.java @@ -853,10 +853,14 @@ public void copy(Path source, if (exists(s3Target)) { if (!actualOptions.contains(StandardCopyOption.REPLACE_EXISTING)) + { throw new FileAlreadyExistsException(format("target already exists: %s", target)); + } if (Files.isDirectory(source)) + { delete(s3Target); + } } if (Files.isDirectory(source)) @@ -896,6 +900,7 @@ private String encodeUrl(final String bucketNameOrigin, { throw new UnsupportedEncodingException("URL could not be encoded: " + e.getMessage()); } + return encodedUrl; }