Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop unnecessary stat #3959

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/unreleased/drop-unnecessary-stat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: drop unnecessary stat

https://github.com/cs3org/reva/pull/3959
25 changes: 5 additions & 20 deletions pkg/storage/utils/metadata/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,36 +396,21 @@ func (cs3 *CS3) MakeDirIfNotExist(ctx context.Context, folder string) error {
Path: utils.MakeRelativePath(folder),
}

resp, err := client.Stat(ctx, &provider.StatRequest{
resp, err := client.CreateContainer(ctx, &provider.CreateContainerRequest{
Ref: rootPathRef,
})

if err != nil {
return err
}

switch {
case err != nil:
return err
case resp.Status.Code == rpc.Code_CODE_OK:
// nothing to do in this case
case resp.Status.Code == rpc.Code_CODE_NOT_FOUND:
r, err := client.CreateContainer(ctx, &provider.CreateContainerRequest{
Ref: rootPathRef,
})

if err != nil {
return err
}

if r.Status.Code != rpc.Code_CODE_OK {
return errtypes.NewErrtypeFromStatus(r.Status)
}
return nil
case resp.Status.Code == rpc.Code_CODE_ALREADY_EXISTS:
// nothing to do in this case
return nil
default:
return errtypes.NewErrtypeFromStatus(resp.Status)
}

return nil
}

// CreateSymlink creates a symlink
Expand Down