From 62a5552e193a96daf7900ca4dc3c98504589c7fc 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: Wed, 13 Nov 2024 09:47:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E5=86=99=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- godo/files/fs.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/godo/files/fs.go b/godo/files/fs.go index 0f42fe7..624156f 100644 --- a/godo/files/fs.go +++ b/godo/files/fs.go @@ -327,7 +327,9 @@ func HandleCopyFile(w http.ResponseWriter, r *http.Request) { } // 如果是一个复制的加密文件,则隐藏的文件也要复制过去 if IsHaveHiddenFile(basePath, srcPath) { - if err := CopyFile(filepath.Join(basePath, srcPath), filepath.Join(basePath, dstPath)); err != nil { + hiddenSrcPath := filepath.Join(basePath, filepath.Dir(srcPath), "."+filepath.Base(srcPath)) + hiddenDstPath := filepath.Join(basePath, filepath.Dir(dstPath), "."+filepath.Base(dstPath)) + if err := CopyFile(hiddenSrcPath, hiddenDstPath); err != nil { libs.HTTPError(w, http.StatusInternalServerError, err.Error()) return } @@ -382,9 +384,8 @@ func HandleWriteFile(w http.ResponseWriter, r *http.Request) { // 没有加密写入明文 if !ispwd { - _, err := io.Copy(file, fileContent) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) + if _, err := file.Write(filedata); err != nil { + libs.HTTPError(w, http.StatusInternalServerError, err.Error()) return } CheckAddDesktop(filePath)