[#368] Unify cache value deletion

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-03-15 12:37:56 +03:00 committed by Kirillov Denis
parent e7b742df4d
commit 02f4524d67
3 changed files with 7 additions and 7 deletions

View file

@ -890,9 +890,9 @@ func (n *layer) DeleteBucket(ctx context.Context, p *DeleteBucketParams) error {
return errors.GetAPIError(errors.ErrBucketNotEmpty) return errors.GetAPIError(errors.ErrBucketNotEmpty)
} }
n.bucketCache.Delete(bucketInfo.Name)
if err = n.deleteContainer(ctx, bucketInfo.CID); err != nil { if err = n.deleteContainer(ctx, bucketInfo.CID); err != nil {
return err return err
} }
n.bucketCache.Delete(bucketInfo.Name)
return nil return nil
} }

View file

@ -189,17 +189,17 @@ func (n *layer) objectPut(ctx context.Context, bkt *data.BucketInfo, p *PutObjec
n.prepareAuthParameters(ctx, &prm.PrmAuth) n.prepareAuthParameters(ctx, &prm.PrmAuth)
id, err := n.neoFS.CreateObject(ctx, prm)
if err != nil {
return nil, n.transformNeofsError(ctx, err)
}
if p.Header[VersionsDeleteMarkAttr] == DelMarkFullObject { if p.Header[VersionsDeleteMarkAttr] == DelMarkFullObject {
if last := versions.getLast(); last != nil { if last := versions.getLast(); last != nil {
n.objCache.Delete(last.Address()) n.objCache.Delete(last.Address())
} }
} }
id, err := n.neoFS.CreateObject(ctx, prm)
if err != nil {
return nil, n.transformNeofsError(ctx, err)
}
meta, err := n.objectHead(ctx, bkt.CID, id) meta, err := n.objectHead(ctx, bkt.CID, id)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -51,13 +51,13 @@ func (n *layer) deleteSystemObject(ctx context.Context, bktInfo *data.BucketInfo
return err return err
} }
n.systemCache.Delete(systemObjectKey(bktInfo, name))
for i := range ids { for i := range ids {
if err = n.objectDelete(ctx, bktInfo.CID, &ids[i]); err != nil { if err = n.objectDelete(ctx, bktInfo.CID, &ids[i]); err != nil {
return err return err
} }
} }
n.systemCache.Delete(systemObjectKey(bktInfo, name))
return nil return nil
} }