Updata:解决冲突
This commit is contained in:
commit
01d54a8f96
@ -2,6 +2,7 @@ package file
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fonchain-fiee/api/files"
|
||||
"fonchain-fiee/pkg/service"
|
||||
@ -291,22 +292,28 @@ func SecurityScan(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 使用独立的 context,避免原请求 context 被取消
|
||||
// scanCtx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
// defer cancel()
|
||||
// 执行安全扫描
|
||||
go func() {
|
||||
// 使用独立的 context,避免原请求 context 被取消
|
||||
scanCtx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
defer cancel()
|
||||
// 执行安全扫描
|
||||
|
||||
resp, err := service.FilesProvider.SecurityScan(ctx, &req)
|
||||
if err != nil {
|
||||
// 记录错误日志
|
||||
zap.L().Error("安全扫描失败",
|
||||
zap.String("url", req.Url),
|
||||
zap.String("fileName", req.FileName),
|
||||
zap.Error(err))
|
||||
service.Error(ctx, errors.New("安全扫描失败"))
|
||||
}
|
||||
|
||||
service.Success(ctx, resp)
|
||||
_, err := service.FilesProvider.SecurityScan(scanCtx, &req)
|
||||
if err != nil {
|
||||
// 记录错误日志
|
||||
zap.L().Error("安全扫描失败",
|
||||
zap.String("url", req.Url),
|
||||
zap.String("fileName", req.FileName),
|
||||
zap.Error(err))
|
||||
} else {
|
||||
zap.L().Info("安全扫描完成",
|
||||
zap.String("url", req.Url),
|
||||
zap.String("fileName", req.FileName))
|
||||
}
|
||||
}()
|
||||
service.Success(ctx, gin.H{
|
||||
"message": "安全扫描任务已提交,正在后台处理",
|
||||
})
|
||||
}
|
||||
|
||||
func UpdateFileSecurityStatus(ctx *gin.Context) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user