fix(pricetrack): ASIN文件路径防本地路径误提交+fileKey兜底反查

This commit is contained in:
2026-09-08 13:34:08 +08:00
parent 7b6f62f1bc
commit 4ac8f8b472
2 changed files with 28 additions and 17 deletions
@@ -86,6 +86,7 @@ public class PriceTrackTaskService {
private final TaskFileJobService taskFileJobService;
private final TaskDistributedLockService taskDistributedLockService;
private final TaskProgressLightAssembler taskProgressLightAssembler;
private final com.nanri.aiimage.modules.file.service.LocalFileStorageService localFileStorageService;
private FileTaskEntity loadTaskForExecution(Long taskId) {
Map<Long, FileTaskEntity> cachedTasks = priceTrackTaskCacheService.getTaskCacheBatch(List.of(taskId));
@@ -1463,7 +1464,14 @@ public class PriceTrackTaskService {
}
File file = new File(rawPath);
if (!file.isFile()) {
throw new BusinessException("ASIN file not found: " + rawPath);
// 直接路径不可读时兜底:按上传返回的 fileKey 反查服务器本地临时目录
File resolved = localFileStorageService.findLocalSourceFile(rawPath);
if (resolved != null) {
file = resolved;
}
}
if (!file.isFile()) {
throw new BusinessException("ASIN 文件不存在或不可读: " + rawPath);
}
String lowerName = file.getName().toLowerCase(Locale.ROOT);
if (lowerName.endsWith(".csv")) {