From 0373cc3725bd6840737a6a549ca6ef16d79e88d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 8 Jun 2023 17:16:05 +0200 Subject: [PATCH] drop unnecessary stat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/drop-unnecessary-stat.md | 3 +++ pkg/storage/utils/metadata/cs3.go | 25 ++++--------------- 2 files changed, 8 insertions(+), 20 deletions(-) create mode 100644 changelog/unreleased/drop-unnecessary-stat.md diff --git a/changelog/unreleased/drop-unnecessary-stat.md b/changelog/unreleased/drop-unnecessary-stat.md new file mode 100644 index 0000000000..279cd75d08 --- /dev/null +++ b/changelog/unreleased/drop-unnecessary-stat.md @@ -0,0 +1,3 @@ +Bugfix: drop unnecessary stat + +https://github.com/cs3org/reva/pull/3959 diff --git a/pkg/storage/utils/metadata/cs3.go b/pkg/storage/utils/metadata/cs3.go index a536f9284e..d271b7e778 100644 --- a/pkg/storage/utils/metadata/cs3.go +++ b/pkg/storage/utils/metadata/cs3.go @@ -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