Fix incorrect file path resolution when using {currentFilename} in naming pattern

This commit is contained in:
aditya.chandel
2025-07-21 23:08:45 -06:00
committed by Aditya Chandel
parent 4fe00e3bce
commit a15eb8684f

View File

@@ -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();