mirror of https://github.com/1Panel-dev/1Panel
fix: 解决文件上传权限错误的问题 (#4563)
parent
ef5a13f87f
commit
4832081b82
|
@ -596,7 +596,7 @@ func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int)
|
|||
dstDir = strings.TrimSpace(dstDir)
|
||||
mode, _ := files.GetParentMode(dstDir)
|
||||
if mode == 0 {
|
||||
mode = os.ModePerm
|
||||
mode = 0755
|
||||
}
|
||||
if _, err := os.Stat(dstDir); err != nil && os.IsNotExist(err) {
|
||||
if err = op.CreateDir(dstDir, mode); err != nil {
|
||||
|
|
|
@ -57,7 +57,14 @@ func (f FileOp) CreateDir(dst string, mode fs.FileMode) error {
|
|||
if err := f.Fs.MkdirAll(dst, mode); err != nil {
|
||||
return err
|
||||
}
|
||||
return f.ChmodR(dst, int64(mode), true)
|
||||
modStr := fmt.Sprintf("%o", mode)
|
||||
|
||||
modeInt, err := strconv.ParseInt(modStr, 10, 64)
|
||||
if err != nil {
|
||||
modeInt = 0755
|
||||
}
|
||||
|
||||
return f.ChmodR(dst, modeInt, true)
|
||||
}
|
||||
|
||||
func (f FileOp) CreateFile(dst string) error {
|
||||
|
|
|
@ -129,7 +129,7 @@ func GetParentMode(path string) (os.FileMode, error) {
|
|||
for {
|
||||
fileInfo, err := os.Stat(absPath)
|
||||
if err == nil {
|
||||
return fileInfo.Mode(), nil
|
||||
return fileInfo.Mode() & os.ModePerm, nil
|
||||
}
|
||||
if !os.IsNotExist(err) {
|
||||
return 0, err
|
||||
|
|
Loading…
Reference in New Issue