From 7ecdadbb5e4f40b6b58392bd07af617458453837 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Fri, 26 Apr 2024 15:57:19 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E4=BC=98=E5=8C=96=E7=BD=91=E7=AB=99?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8F=8F=E8=BF=B0=E4=BF=A1=E6=81=AF=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/utils/files/file_op.go | 3 +-- backend/utils/files/utils.go | 8 +++----- backend/utils/http/get.go | 1 - frontend/src/views/website/website/index.vue | 12 ++++++------ 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/backend/utils/files/file_op.go b/backend/utils/files/file_op.go index b0ff04c9b3e4..7355d1708637 100644 --- a/backend/utils/files/file_op.go +++ b/backend/utils/files/file_op.go @@ -314,6 +314,7 @@ func (f FileOp) DownloadFile(url, dst string) error { if err != nil { return err } + defer resp.Body.Close() out, err := os.Create(dst) if err != nil { @@ -324,8 +325,6 @@ func (f FileOp) DownloadFile(url, dst string) error { if _, err = io.Copy(out, resp.Body); err != nil { return fmt.Errorf("save download file [%s] error, err %s", dst, err.Error()) } - out.Close() - resp.Body.Close() return nil } diff --git a/backend/utils/files/utils.go b/backend/utils/files/utils.go index f44441db9a97..6dfbd4c4e2c5 100644 --- a/backend/utils/files/utils.go +++ b/backend/utils/files/utils.go @@ -3,7 +3,6 @@ package files import ( "bufio" "fmt" - "github.com/spf13/afero" "io" "net/http" "os" @@ -12,6 +11,8 @@ import ( "strconv" "strings" "sync" + + "github.com/spf13/afero" ) func IsSymlink(mode os.FileMode) bool { @@ -144,8 +145,5 @@ func GetParentMode(path string) (os.FileMode, error) { } func IsInvalidChar(name string) bool { - if strings.Contains(name, "&") { - return true - } - return false + return strings.Contains(name, "&") } diff --git a/backend/utils/http/get.go b/backend/utils/http/get.go index 1f8255d6c590..66a9aed1bb45 100644 --- a/backend/utils/http/get.go +++ b/backend/utils/http/get.go @@ -43,7 +43,6 @@ func GetHttpRes(url string) (*http.Response, error) { return nil, buserr.WithMap("ErrHttpReqFailed", map[string]interface{}{"err": err.Error()}, err) } } - defer resp.Body.Close() if resp.StatusCode == 404 { return nil, buserr.New("ErrHttpReqNotFound") } diff --git a/frontend/src/views/website/website/index.vue b/frontend/src/views/website/website/index.vue index 6d284884bbfc..9f04bfadeb48 100644 --- a/frontend/src/views/website/website/index.vue +++ b/frontend/src/views/website/website/index.vue @@ -111,11 +111,12 @@ - - - +