From 2575462daa69b013bceec47981d698a3be6ae72b Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 17 May 2022 16:03:38 +0300 Subject: [PATCH] [#439] Less cache misses for empty bucket setting Signed-off-by: Alex Vanin --- api/layer/system_object.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/api/layer/system_object.go b/api/layer/system_object.go index 72d498eb3..983ded5fe 100644 --- a/api/layer/system_object.go +++ b/api/layer/system_object.go @@ -238,16 +238,14 @@ func (n *layer) GetBucketSettings(ctx context.Context, bktInfo *data.BucketInfo) return settings, nil } + settings := &data.BucketSettings{} + obj, err := n.getSystemObjectFromNeoFS(ctx, bktInfo, bktInfo.SettingsObjectName()) if err != nil { - if errors.IsS3Error(err, errors.ErrNoSuchKey) { - return &data.BucketSettings{}, nil + if !errors.IsS3Error(err, errors.ErrNoSuchKey) { + return nil, err } - return nil, err - } - - settings := &data.BucketSettings{} - if err = json.Unmarshal(obj.Payload(), settings); err != nil { + } else if err = json.Unmarshal(obj.Payload(), settings); err != nil { return nil, err }