Skip to content

Commit

Permalink
fileNames to filenames
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
  • Loading branch information
etiennehomer committed Nov 7, 2024
1 parent 97c4f56 commit 16a7625
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/powsybl/caseserver/service/S3CaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,25 +311,25 @@ private static String removeExtension(String filename, String extension) {
}

public Set<String> listName(UUID caseUuid, String regex) {
List<String> fileNames;
List<String> filenames;
String originalFilename = getOriginalFilename(caseUuid);
if (isCompressedCaseFile(originalFilename)) {
// For a compressed file basename.xml.gz, listName() should return ['basename.xml']. That's why we remove the compression extension to the filename.
fileNames = List.of(removeExtension(originalFilename, "." + originalFilename));
filenames = List.of(removeExtension(originalFilename, "." + originalFilename));
} else {
List<S3Object> s3Objects = getCaseS3Objects(caseUuid);
fileNames = s3Objects.stream().map(obj -> Paths.get(obj.key()).toString().replace(CASES_PREFIX + caseUuid.toString() + DELIMITER, "")).toList();
filenames = s3Objects.stream().map(obj -> Paths.get(obj.key()).toString().replace(CASES_PREFIX + caseUuid.toString() + DELIMITER, "")).toList();
// For archived cases :
if (isArchivedCaseFile(originalFilename)) {
fileNames = fileNames.stream()
filenames = filenames.stream()
// the original archive name has to be filtered.
.filter(name -> !name.equals(originalFilename))
// each subfile hase been gzipped -> we have to remove the gz extension (only one, the one we added).
.map(name -> removeExtension(name, GZIP_EXTENSION))
.collect(Collectors.toList());
}
}
return fileNames.stream().filter(n -> n.matches(regex)).collect(Collectors.toSet());
return filenames.stream().filter(n -> n.matches(regex)).collect(Collectors.toSet());
}

@Override
Expand Down

0 comments on commit 16a7625

Please sign in to comment.