From a15eb8684fd299e9e09cac2104f0c8e68ed2faf2 Mon Sep 17 00:00:00 2001 From: "aditya.chandel" Date: Mon, 21 Jul 2025 23:08:45 -0600 Subject: [PATCH] Fix incorrect file path resolution when using {currentFilename} in naming pattern --- .../booklore/service/bookdrop/BookDropService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/bookdrop/BookDropService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/bookdrop/BookDropService.java index 59a56ccbc..eeb9d637a 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/service/bookdrop/BookDropService.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/bookdrop/BookDropService.java @@ -20,6 +20,7 @@ import com.adityachandel.booklore.util.FileUtils; import com.adityachandel.booklore.util.PathPatternResolver; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FilenameUtils; import org.springframework.core.io.PathResource; import org.springframework.core.io.Resource; import org.springframework.stereotype.Service; @@ -105,7 +106,7 @@ public class BookDropService { filePattern += "{currentFilename}"; } - String relativePath = PathPatternResolver.resolvePattern(metadata, filePattern, bookdropFile.getFilePath()); + String relativePath = PathPatternResolver.resolvePattern(metadata, filePattern, FilenameUtils.getName(bookdropFile.getFilePath())); Path source = Path.of(bookdropFile.getFilePath()); Path target = Paths.get(path.getPath(), relativePath); File targetFile = target.toFile();