2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 13:47:15 +08:00

feat(文件): 优化解压,保存时的权限设置

This commit is contained in:
耗子
2024-10-31 12:35:31 +08:00
parent 1b6086bb0b
commit 2cbc641b2d

View File

@@ -107,7 +107,6 @@ func (s *FileService) Save(w http.ResponseWriter, r *http.Request) {
return
}
s.setPermission(req.Path, 0755, "www", "www")
Success(w, nil)
}
@@ -333,12 +332,30 @@ func (s *FileService) UnCompress(w http.ResponseWriter, r *http.Request) {
return
}
oldList, err := io.ReadDir(req.Path)
if err != nil {
Error(w, http.StatusInternalServerError, "%v", err)
return
}
if err = io.UnCompress(req.File, req.Path); err != nil {
Error(w, http.StatusInternalServerError, "%v", err)
return
}
s.setPermission(req.Path, 0755, "www", "www")
currentList, err := io.ReadDir(req.Path)
if err != nil {
Error(w, http.StatusInternalServerError, "%v", err)
return
}
// 取新增的设置权限
for _, currentDir := range currentList {
if !slices.Contains(oldList, currentDir) {
s.setPermission(filepath.Join(req.Path, currentDir.Name()), 0755, "www", "www")
}
}
Success(w, nil)
}