From 3dd3ae9fc6cfda491df1feffd08ca65824945f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=AD=90=E6=97=BA?= <15039612+liu-ziwang123@user.noreply.gitee.com> Date: Tue, 12 Nov 2024 18:02:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=A1=A5=E5=85=85=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E6=96=87=E4=BB=B6=E7=BC=BA=E5=B0=91=E7=9A=84?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- godo/cmd/serve.go | 2 +- godo/files/fs.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/godo/cmd/serve.go b/godo/cmd/serve.go index 849c7e2..993627d 100644 --- a/godo/cmd/serve.go +++ b/godo/cmd/serve.go @@ -86,7 +86,7 @@ func (l loggingMiddleware) Middleware(next http.Handler) http.Handler { // CORS 中间件 func corsMiddleware() mux.MiddlewareFunc { - allowHeaders := "Content-Type, Accept, Authorization, Origin,pwd,salt" + allowHeaders := "Content-Type, Accept, Authorization, Origin,Pwd,Salt" allowMethods := "GET, POST, PUT, DELETE, OPTIONS" return func(next http.Handler) http.Handler { diff --git a/godo/files/fs.go b/godo/files/fs.go index 29c8dd6..ec9fd03 100644 --- a/godo/files/fs.go +++ b/godo/files/fs.go @@ -182,6 +182,12 @@ func HandleUnlink(w http.ResponseWriter, r *http.Request) { libs.HTTPError(w, http.StatusConflict, err.Error()) return } + // 如果有同名隐藏文件,也要删除掉 + hiddenFilePath := filepath.Join(basePath, filepath.Dir(path), "."+filepath.Base(path)) + _, err = os.Stat(hiddenFilePath) + if err == nil { + os.Remove(hiddenFilePath) + } res := libs.APIResponse{Message: fmt.Sprintf("File '%s' successfully removed.", path)} json.NewEncoder(w).Encode(res) }