You've already forked FrameTour-BE
支持跳过景区文件删除,跳过重复adapter
This commit is contained in:
@ -33,11 +33,13 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.ycwl.basic.constant.FaceConstant.USER_FACE_DB_NAME;
|
||||
import static com.ycwl.basic.constant.StorageConstant.VIID_FACE;
|
||||
|
||||
@Component
|
||||
@EnableScheduling
|
||||
@ -58,6 +60,7 @@ public class FaceCleaner {
|
||||
private FaceMapper faceMapper;
|
||||
@Autowired
|
||||
private ScenicService scenicService;
|
||||
public static final List<String> disableDeleteScenicIds = List.of("3955650120997015552");
|
||||
|
||||
@Scheduled(cron = "0 0 1 * * ?")
|
||||
public void deleteExpireSample(){
|
||||
@ -217,9 +220,9 @@ public class FaceCleaner {
|
||||
}
|
||||
private void cleanFaceSampleOss() {
|
||||
log.info("开始清理人脸文件");
|
||||
List<FaceSampleRespVO> faceSampleRespVOS = faceSampleMapper.list(new FaceSampleReqQuery());
|
||||
List<FaceSampleRespVO> list = faceSampleMapper.list(new FaceSampleReqQuery());
|
||||
IStorageAdapter adapter = StorageFactory.use("faces");
|
||||
List<StorageFileObject> fileObjectList = adapter.listDir("user-face");
|
||||
List<StorageFileObject> fileObjectList = adapter.listDir(VIID_FACE);
|
||||
fileObjectList.parallelStream().forEach(fileObject -> {
|
||||
if (fileObject.getModifyTime() != null) {
|
||||
// 如果是一天以内修改的,则跳过
|
||||
@ -227,7 +230,7 @@ public class FaceCleaner {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(faceSampleRespVOS.parallelStream().noneMatch(faceSampleRespVO -> faceSampleRespVO.getFaceUrl().contains(fileObject.getName()))){
|
||||
if(list.parallelStream().noneMatch(faceSampleRespVO -> faceSampleRespVO.getFaceUrl().contains(fileObject.getName()))){
|
||||
log.info("删除人脸文件:{}", fileObject);
|
||||
adapter.deleteFile(fileObject.getFullPath());
|
||||
}
|
||||
@ -236,8 +239,20 @@ public class FaceCleaner {
|
||||
public void cleanSourceOss() {
|
||||
log.info("开始清理源视频素材文件");
|
||||
List<SourceRespVO> list = sourceMapper.list(new SourceReqQuery());
|
||||
ArrayList<String> adapterIdentity = new ArrayList<>();
|
||||
scenicMapper.list(new ScenicReqQuery()).forEach(scenic -> {
|
||||
if (disableDeleteScenicIds.contains(scenic.getId().toString())) {
|
||||
log.info("景区【{}】禁止删除文件,跳过!", scenic.getName());
|
||||
return;
|
||||
}
|
||||
IStorageAdapter adapter = scenicService.getScenicStorageAdapter(scenic.getId());
|
||||
String identity = adapter.identity();
|
||||
if (!adapterIdentity.contains(identity)) {
|
||||
log.info("因为Identity相同,跳过");
|
||||
adapterIdentity.add(identity);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
log.info("开始清理视频文件");
|
||||
List<StorageFileObject> fileObjectList = adapter.listDir(StorageConstant.VIDEO_PIECE_PATH);
|
||||
fileObjectList.parallelStream().forEach(fileObject -> {
|
||||
@ -275,8 +290,20 @@ public class FaceCleaner {
|
||||
public void cleanVideoOss() {
|
||||
log.info("开始清理视频文件");
|
||||
List<VideoRespVO> list = videoMapper.list(new VideoReqQuery());
|
||||
ArrayList<String> adapterIdentity = new ArrayList<>();
|
||||
scenicMapper.list(new ScenicReqQuery()).forEach(scenic -> {
|
||||
if (disableDeleteScenicIds.contains(scenic.getId().toString())) {
|
||||
log.info("景区【{}】禁止删除文件,跳过!", scenic.getName());
|
||||
return;
|
||||
}
|
||||
IStorageAdapter adapter = scenicService.getScenicStorageAdapter(scenic.getId());
|
||||
String identity = adapter.identity();
|
||||
if (!adapterIdentity.contains(identity)) {
|
||||
adapterIdentity.add(identity);
|
||||
} else {
|
||||
log.info("因为Identity相同,跳过");
|
||||
return;
|
||||
}
|
||||
log.info("开始清理视频文件");
|
||||
List<StorageFileObject> fileObjectList = adapter.listDir(StorageConstant.VLOG_PATH);
|
||||
fileObjectList.parallelStream().forEach(fileObject -> {
|
||||
|
Reference in New Issue
Block a user