diff --git a/src/main/java/com/powsybl/caseserver/service/S3CaseService.java b/src/main/java/com/powsybl/caseserver/service/S3CaseService.java index cf1f45e..9e1ed88 100644 --- a/src/main/java/com/powsybl/caseserver/service/S3CaseService.java +++ b/src/main/java/com/powsybl/caseserver/service/S3CaseService.java @@ -187,7 +187,7 @@ private String parseFilenameFromKey(String key) { } public String uuidToKeyPrefix(UUID uuid) { - return rootDirectory + uuid.toString() + DELIMITER; + return rootDirectory + DELIMITER + uuid.toString() + DELIMITER; } public String uuidToKeyWithFileName(UUID uuid, String filename) { @@ -254,7 +254,7 @@ public Optional getCaseBytes(UUID caseUuid) { public List getCases() { List caseInfosList = new ArrayList<>(); CaseInfos caseInfos; - for (S3Object o : getCaseS3Objects(rootDirectory)) { + for (S3Object o : getCaseS3Objects(rootDirectory + DELIMITER)) { caseInfos = getCaseInfos(parseUuidFromKey(o.key())); if (Objects.nonNull(caseInfos)) { caseInfosList.add(caseInfos); @@ -319,7 +319,7 @@ public Set listName(UUID caseUuid, String regex) { filenames = List.of(removeExtension(originalFilename, "." + getCompressionFormat(caseUuid))); } else { List s3Objects = getCaseS3Objects(caseUuid); - filenames = s3Objects.stream().map(obj -> Paths.get(obj.key()).toString().replace(rootDirectory + caseUuid.toString() + DELIMITER, "")).toList(); + filenames = s3Objects.stream().map(obj -> Paths.get(obj.key()).toString().replace(rootDirectory + DELIMITER + caseUuid.toString() + DELIMITER, "")).toList(); // For archived cases : if (isArchivedCaseFile(originalFilename)) { filenames = filenames.stream() @@ -411,9 +411,9 @@ private void copyEntry(UUID sourcecaseUuid, UUID caseUuid, String fileName) { // To optimize copy, files to copy are not downloaded on the case-server. They are directly copied on the S3 server. CopyObjectRequest copyObjectRequest = CopyObjectRequest.builder() .sourceBucket(bucketName) - .sourceKey(rootDirectory + sourcecaseUuid + DELIMITER + fileName) + .sourceKey(rootDirectory + DELIMITER + sourcecaseUuid + DELIMITER + fileName) .destinationBucket(bucketName) - .destinationKey(rootDirectory + caseUuid + DELIMITER + fileName) + .destinationKey(rootDirectory + DELIMITER + caseUuid + DELIMITER + fileName) .build(); try { s3Client.copyObject(copyObjectRequest); @@ -526,7 +526,7 @@ public void deleteCase(UUID caseUuid) { public void deleteAllCases() { ListObjectsV2Request listObjectsRequest = ListObjectsV2Request.builder() .bucket(bucketName) - .prefix(rootDirectory) + .prefix(rootDirectory + DELIMITER) .build(); ListObjectsV2Response listObjectsResponse = s3Client.listObjectsV2(listObjectsRequest); diff --git a/src/main/resources/config/application.yaml b/src/main/resources/config/application.yaml index 22274e7..65ec4d6 100644 --- a/src/main/resources/config/application.yaml +++ b/src/main/resources/config/application.yaml @@ -30,4 +30,4 @@ cleaning-cases-cron: 0 * 2 * * ? storage: type: FS # FS or S3 s3: - rootDirectory: cases/ + rootDirectory: cases