You've already forked VptPassiveAdapter
优化切割逻辑,提前判断是否成功
This commit is contained in:
14
core/task.go
14
core/task.go
@ -11,7 +11,6 @@ import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
@ -55,19 +54,6 @@ func HandleTask(ctx context.Context, device config.DeviceMapping, task dto.Task)
|
||||
span.SetStatus(codes.Error, "ffmpeg任务执行失败")
|
||||
return nil, fmt.Errorf("ffmpeg任务执行失败")
|
||||
}
|
||||
outfile, err := os.Stat(constructTask.OutputFile)
|
||||
if err != nil {
|
||||
span.SetAttributes(attribute.String("error", err.Error()))
|
||||
span.SetStatus(codes.Error, "文件不存在")
|
||||
return nil, fmt.Errorf("文件不存在:%s", constructTask.OutputFile)
|
||||
}
|
||||
span.SetAttributes(attribute.String("file.name", outfile.Name()))
|
||||
span.SetAttributes(attribute.Int64("file.size", outfile.Size()))
|
||||
if outfile.Size() < 4096 {
|
||||
span.SetAttributes(attribute.String("error", "文件大小过小"))
|
||||
span.SetStatus(codes.Error, "文件大小过小")
|
||||
return nil, fmt.Errorf("文件大小过小:%s", constructTask.OutputFile)
|
||||
}
|
||||
return &dto.FileObject{
|
||||
CreateTime: task.EndTime,
|
||||
EndTime: task.EndTime,
|
||||
|
Reference in New Issue
Block a user