mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 11:27:17 +08:00
feat(文件): 优化解压,保存时的权限设置
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user