Skip to content

Commit

Permalink
Fix: move makeDir downside into op/fs.go to cover all the cases of cr…
Browse files Browse the repository at this point in the history
…eate multi-level file
  • Loading branch information
akang943578 committed Jun 28, 2024
1 parent 6f85663 commit 7ae7857
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/op/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,21 @@ func Get(ctx context.Context, storage driver.Driver, path string) (model.Obj, er

// not root folder
dir, name := stdpath.Split(path)

// makeDir default set to true, you can set it to false by context in some cases
// ctx = context.WithValue(ctx, "makeDir", false)
makeDir, ok := ctx.Value("makeDir").(bool)
if !ok {
makeDir = true
}
if makeDir {
log.Debugf("make dir: %s", dir)
err := MakeDir(ctx, storage, dir)
if err != nil {
return nil, errors.WithMessagef(err, "failed to make dir [%s]", dir)
}
}

files, err := List(ctx, storage, dir, model.ListArgs{})
if err != nil {
return nil, errors.WithMessage(err, "failed get parent list")
Expand Down

0 comments on commit 7ae7857

Please sign in to comment.