Skip to content

Commit

Permalink
LocalFS already creates directories
Browse files Browse the repository at this point in the history
  • Loading branch information
marino39 committed Sep 23, 2024
1 parent 3ab8711 commit 83f58ff
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,7 @@ func (f *File) Create(ctx context.Context, fs storage.FS) (io.WriteCloser, error
f.mu.Lock()
defer f.mu.Unlock()

filePath := f.Path()
if _, ok := fs.(*local.LocalFS); ok {
var err error
dirPath := path.Dir(filePath)
if _, err = os.Stat(dirPath); os.IsNotExist(err) {
err = os.MkdirAll(dirPath, 0755)
}
if err != nil {
return nil, fmt.Errorf("failed to create file directory")
}
}
return fs.Create(ctx, filePath, nil)
return fs.Create(ctx, f.Path(), nil)
}

func (f *File) Open(ctx context.Context, fs storage.FS) (io.ReadCloser, error) {
Expand Down

0 comments on commit 83f58ff

Please sign in to comment.