Skip to content

Commit d38506f

Browse files
fix: 修复上传前回调错误:record not found
1 parent 25250ea commit d38506f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

template/admin/upload/upload.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func (p *Template) HandleFromBase64(ctx *quark.Context) error {
253253

254254
// 上传前回调
255255
getFileSystem, fileInfo, err := template.BeforeHandle(ctx, fileSystem)
256-
if err != nil {
256+
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
257257
return ctx.CJSONError(err.Error())
258258
}
259259
if fileInfo != nil {

template/tool/upload/upload.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package upload
33
import (
44
"bytes"
55
"encoding/base64"
6+
"errors"
67
"io"
78
"mime/multipart"
89
"reflect"
@@ -11,6 +12,7 @@ import (
1112

1213
"github.com/quarkcloudio/quark-go/v3"
1314
"github.com/quarkcloudio/quark-go/v3/dal/db"
15+
"gorm.io/gorm"
1416
)
1517

1618
// 文件上传
@@ -150,7 +152,7 @@ func (p *Template) Handle(ctx *quark.Context) error {
150152
getFileSystem, fileInfo, err := ctx.Template.(interface {
151153
BeforeHandle(ctx *quark.Context, fileSystem *quark.FileSystem) (*quark.FileSystem, *quark.FileInfo, error)
152154
}).BeforeHandle(ctx, fileSystem)
153-
if err != nil {
155+
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
154156
return ctx.JSONError(err.Error())
155157
}
156158
if fileInfo != nil {
@@ -276,7 +278,7 @@ func (p *Template) HandleFromBase64(ctx *quark.Context) error {
276278
getFileSystem, fileInfo, err := ctx.Template.(interface {
277279
BeforeHandle(ctx *quark.Context, fileSystem *quark.FileSystem) (*quark.FileSystem, *quark.FileInfo, error)
278280
}).BeforeHandle(ctx, fileSystem)
279-
if err != nil {
281+
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
280282
return ctx.JSONError(err.Error())
281283
}
282284
if fileInfo != nil {

0 commit comments

Comments
 (0)