diff --git a/core/task.go b/core/task.go index 8f886de..79afb22 100644 --- a/core/task.go +++ b/core/task.go @@ -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, diff --git a/util/ffmpeg.go b/util/ffmpeg.go index 9135b03..83cc309 100644 --- a/util/ffmpeg.go +++ b/util/ffmpeg.go @@ -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 }