task-33: 将店铺源文件 key 映射改为确定路径,取消临时目录递归扫描
This commit is contained in:
+15
-2
@@ -96,13 +96,26 @@ public class LocalFileStorageService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺源文件 key → 确定路径解析:saveTempFile 始终把源文件平铺写入
|
||||
* localTempDir/<fileKey>[.<ext>],因此这里只列举临时目录根层(非递归),
|
||||
* 匹配 name == fileKey 或 fileKey.<ext> 的直接子文件,
|
||||
* 取代原 FileUtil.loopFiles 对整棵临时目录树的递归前缀扫描。
|
||||
*/
|
||||
public File findLocalSourceFile(String fileKey) {
|
||||
if (fileKey == null || fileKey.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
File baseDir = FileUtil.file(storageProperties.getLocalTempDir());
|
||||
if (!baseDir.exists()) {
|
||||
return null;
|
||||
}
|
||||
List<File> matchedFiles = FileUtil.loopFiles(baseDir, pathname -> pathname.isFile() && pathname.getName().startsWith(fileKey));
|
||||
return matchedFiles.isEmpty() ? null : matchedFiles.getFirst();
|
||||
File[] matchedFiles = baseDir.listFiles(pathname -> pathname.isFile()
|
||||
&& (pathname.getName().equals(fileKey) || pathname.getName().startsWith(fileKey + ".")));
|
||||
if (matchedFiles == null) {
|
||||
return null;
|
||||
}
|
||||
return matchedFiles.length == 0 ? null : matchedFiles[0];
|
||||
}
|
||||
|
||||
private String normalizeCellText(String value) {
|
||||
|
||||
Reference in New Issue
Block a user