文件大小判断

This commit is contained in:
Jerry Yan 2025-03-16 18:02:40 +08:00
parent b295a8d315
commit b02d75edcd
2 changed files with 9 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import (
"ZhenTuLocalPassiveAdapter/fs"
"ZhenTuLocalPassiveAdapter/util"
"fmt"
"os"
"path"
)
@ -30,6 +31,13 @@ func HandleTask(device config.DeviceMapping, task dto.Task) (*dto.FileObject, er
if !ok {
return nil, fmt.Errorf("ffmpeg任务执行失败")
}
outfile, err := os.Stat(constructTask.OutputFile)
if err != nil {
return nil, fmt.Errorf("文件不存在:%s", constructTask.OutputFile)
}
if outfile.Size() < 4096 {
return nil, fmt.Errorf("文件大小过小:%s", constructTask.OutputFile)
}
return &dto.FileObject{
CreateTime: task.EndTime,
EndTime: task.EndTime,

View File

@ -102,15 +102,11 @@ func runFfmpegForSingleFile(task *dto.FfmpegTask) bool {
if err != nil {
return false
}
outfile, err := os.Stat(task.OutputFile)
_, err = os.Stat(task.OutputFile)
if err != nil {
log.Printf("文件不存在:%s", task.OutputFile)
return false
}
if outfile.Size() < 4096 {
log.Printf("文件大小过小:%s", task.OutputFile)
return false
}
return result
}