Browse Source

fix:修改加密bug

master
刘子旺 7 months ago
parent
commit
5403077e07
  1. 17
      godo/files/fs.go

17
godo/files/fs.go

@ -236,7 +236,15 @@ func HandleRename(w http.ResponseWriter, r *http.Request) {
libs.HTTPError(w, http.StatusConflict, err.Error()) libs.HTTPError(w, http.StatusConflict, err.Error())
return return
} }
// 如果是一个加密文件,则隐藏文件的名字也要改
if IsHaveHiddenFile(basePath, oldPath) {
oldHiddenFilePath := filepath.Join(basePath, filepath.Dir(oldPath), "."+filepath.Base(oldPath))
newHiddenFilePath := filepath.Join(basePath, filepath.Dir(newPath), "."+filepath.Base(newPath))
err = os.Rename(oldHiddenFilePath, newHiddenFilePath)
if err != nil {
log.Printf("Error renaming hidden file: %s", err.Error())
}
}
err = CheckAddDesktop(newPath) err = CheckAddDesktop(newPath)
if err != nil { if err != nil {
log.Printf("Error adding file to desktop: %s", err.Error()) log.Printf("Error adding file to desktop: %s", err.Error())
@ -317,6 +325,13 @@ func HandleCopyFile(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
log.Printf("Error adding file to desktop: %s", err.Error()) log.Printf("Error adding file to desktop: %s", err.Error())
} }
// 如果是一个复制的加密文件,则隐藏的文件也要复制过去
if IsHaveHiddenFile(basePath, srcPath) {
if err := CopyFile(filepath.Join(basePath, srcPath), filepath.Join(basePath, dstPath)); err != nil {
libs.HTTPError(w, http.StatusInternalServerError, err.Error())
return
}
}
res := libs.APIResponse{Message: fmt.Sprintf("File '%s' successfully copied to '%s'.", srcPath, dstPath)} res := libs.APIResponse{Message: fmt.Sprintf("File '%s' successfully copied to '%s'.", srcPath, dstPath)}
json.NewEncoder(w).Encode(res) json.NewEncoder(w).Encode(res)
} }

Loading…
Cancel
Save