Fix incorrect file path resolution when using {currentFilename} in naming pattern
This commit is contained in:
committed by
Aditya Chandel
parent
4fe00e3bce
commit
a15eb8684f
+2
-1
@@ -20,6 +20,7 @@ import com.adityachandel.booklore.util.FileUtils;
|
|||||||
import com.adityachandel.booklore.util.PathPatternResolver;
|
import com.adityachandel.booklore.util.PathPatternResolver;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.springframework.core.io.PathResource;
|
import org.springframework.core.io.PathResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -105,7 +106,7 @@ public class BookDropService {
|
|||||||
filePattern += "{currentFilename}";
|
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 source = Path.of(bookdropFile.getFilePath());
|
||||||
Path target = Paths.get(path.getPath(), relativePath);
|
Path target = Paths.get(path.getPath(), relativePath);
|
||||||
File targetFile = target.toFile();
|
File targetFile = target.toFile();
|
||||||
|
|||||||
Reference in New Issue
Block a user