Skip to content

Commit d8bdc28

Browse files
KirCuteForSourceCodeAnalysis
authored andcommitted
fix(local): cannot mkdir on specific platforms (OpenListTeam#1304)
1 parent 76ae0d2 commit d8bdc28

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/local/driver.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (d *Local) Config() driver.Config {
5252

5353
func (d *Local) Init(ctx context.Context) error {
5454
if d.MkdirPerm == "" {
55-
d.mkdirPerm = 0777
55+
d.mkdirPerm = 0o777
5656
} else {
5757
v, err := strconv.ParseUint(d.MkdirPerm, 8, 32)
5858
if err != nil {
@@ -151,6 +151,7 @@ func (d *Local) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([
151151
}
152152
return files, nil
153153
}
154+
154155
func (d *Local) FileInfoToObj(ctx context.Context, f fs.FileInfo, reqPath string, fullPath string) model.Obj {
155156
thumb := ""
156157
if d.Thumbnail {
@@ -199,7 +200,7 @@ func (d *Local) Get(ctx context.Context, path string) (model.Obj, error) {
199200
path = filepath.Join(d.GetRootPath(), path)
200201
f, err := os.Stat(path)
201202
if err != nil {
202-
if strings.Contains(err.Error(), "cannot find the file") {
203+
if os.IsNotExist(err) {
203204
return nil, errs.ObjectNotFound
204205
}
205206
return nil, err
@@ -376,7 +377,7 @@ func (d *Local) Remove(ctx context.Context, obj model.Obj) error {
376377
}
377378
} else {
378379
if !utils.Exists(d.RecycleBinPath) {
379-
err = os.MkdirAll(d.RecycleBinPath, 0755)
380+
err = os.MkdirAll(d.RecycleBinPath, 0o755)
380381
if err != nil {
381382
return err
382383
}

0 commit comments

Comments
 (0)