mirror of https://github.com/Xhofe/alist
fix!(local): perm on mkdir (close #3626)
parent
81e10f8939
commit
c9c4d6bc7e
|
@ -5,7 +5,6 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/alist-org/alist/v3/server/common"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
@ -21,6 +20,7 @@ import (
|
|||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/sign"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
"github.com/alist-org/alist/v3/server/common"
|
||||
"github.com/disintegration/imaging"
|
||||
_ "golang.org/x/image/webp"
|
||||
)
|
||||
|
@ -28,6 +28,7 @@ import (
|
|||
type Local struct {
|
||||
model.Storage
|
||||
Addition
|
||||
mkdirPerm int32
|
||||
}
|
||||
|
||||
func (d *Local) Config() driver.Config {
|
||||
|
@ -35,8 +36,14 @@ func (d *Local) Config() driver.Config {
|
|||
}
|
||||
|
||||
func (d *Local) Init(ctx context.Context) error {
|
||||
if d.MkdirPerm == 0 {
|
||||
d.MkdirPerm = 777
|
||||
if d.MkdirPerm == "" {
|
||||
d.mkdirPerm = 0777
|
||||
} else {
|
||||
v, err := strconv.ParseUint(d.MkdirPerm, 8, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d.mkdirPerm = int32(v)
|
||||
}
|
||||
if !utils.Exists(d.GetRootPath()) {
|
||||
return fmt.Errorf("root folder %s not exists", d.GetRootPath())
|
||||
|
@ -168,7 +175,7 @@ func (d *Local) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
|
|||
|
||||
func (d *Local) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error {
|
||||
fullPath := filepath.Join(parentDir.GetPath(), dirName)
|
||||
err := os.MkdirAll(fullPath, os.FileMode(d.MkdirPerm))
|
||||
err := os.MkdirAll(fullPath, os.FileMode(d.mkdirPerm))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ type Addition struct {
|
|||
driver.RootPath
|
||||
Thumbnail bool `json:"thumbnail" required:"true" help:"enable thumbnail"`
|
||||
ShowHidden bool `json:"show_hidden" default:"true" required:"false" help:"show hidden directories and files"`
|
||||
MkdirPerm uint32 `json:"mkdir_perm" type:"number" default:"777"`
|
||||
MkdirPerm string `json:"mkdir_perm" default:"777"`
|
||||
}
|
||||
|
||||
var config = driver.Config{
|
||||
|
|
Loading…
Reference in New Issue