更新,sourceId传入无需传url

This commit is contained in:
2025-05-09 10:30:43 +08:00
parent 164e76495e
commit 2bf8bb4df5
2 changed files with 7 additions and 7 deletions

View File

@ -311,11 +311,11 @@ public class VideoPieceGetter {
sourceMapper.addRelation(videoSource);
}
sourceMapper.add(sourceEntity);
videoReUploader.addTask(url, sourceEntity.getId());
videoReUploader.addTask(sourceEntity.getId());
} else {
source.setVideoUrl(url);
sourceMapper.update(source);
videoReUploader.addTask(url, source.getId());
videoReUploader.addTask(source.getId());
}
} else {
// 有原视频

View File

@ -48,7 +48,7 @@ public class VideoReUploader {
@Autowired
private ScenicRepository scenicRepository;
public void addTask(String url, Long sourceId) {
public void addTask(Long sourceId) {
SourceEntity entity = sourceMapper.getEntity(sourceId);
if (entity == null) {
return;
@ -65,16 +65,16 @@ public class VideoReUploader {
}
final String dstFilePath = StorageUtil.joinPath(StorageConstant.VIDEO_PIECE_PATH, entity.getId().toString() + ".mp4");
final IStorageAdapter adapter = scenicService.getScenicStorageAdapter(entity.getScenicId());
if (StringUtils.equals(url, adapter.getUrl(dstFilePath))) {
if (StringUtils.equals(entity.getVideoUrl(), adapter.getUrl(dstFilePath))) {
return;
}
String tmpFilePath = UUID.randomUUID().toString();
executor.execute(() -> {
// 先下载,后上传
File dstFile = new File(tmpFilePath);
log.info("下载视频:{}sourceId{}", url, sourceId);
long size = HttpUtil.downloadFile(url, dstFile);
log.info("下载视频完成:{};大小:{}sourceId{}", url, size, sourceId);
log.info("下载视频:{}sourceId{}", entity.getVideoUrl(), sourceId);
long size = HttpUtil.downloadFile(entity.getVideoUrl(), dstFile);
log.info("下载视频完成:{};大小:{}sourceId{}", entity.getVideoUrl(), size, sourceId);
try {
log.info("开始上传:{}sourceId{}", dstFilePath, sourceId);
String newUrl = adapter.uploadFile("video/mp4", dstFile, dstFilePath);