From 8eb1afbcb8d5385d1f9e15099c20b6708afdf50f Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Wed, 10 Aug 2022 04:04:26 +0400 Subject: [PATCH] [#645] Replace tagging when PutObject Signed-off-by: Angira Kekteeva --- CHANGELOG.md | 3 ++- internal/neofs/tree.go | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6087f497b..cc0d2228f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ This document outlines major changes between releases. - Improved wallet configuration via `.yaml` config and environment variables (#607) ### Removed ### Fixed -- Responses to `GetObject` and `HeadObject`: remove redundant `VersionID` (#577) +- Responses to `GetObject` and `HeadObject`: removed redundant `VersionID` (#577) +- Replacement of object tagging in case of overwriting of an object (#645) ### Updating from v0.23.0 1. Make sure configuration of wallet is valid. If you use: 1. environment variables: set `S3_GW_WALLET_PATH` instead of `S3_GW_WALLET`, diff --git a/internal/neofs/tree.go b/internal/neofs/tree.go index f1c932908..811011987 100644 --- a/internal/neofs/tree.go +++ b/internal/neofs/tree.go @@ -1082,7 +1082,11 @@ func (c *TreeClient) addVersion(ctx context.Context, cnrID cid.ID, treeID string return err } - return c.moveNode(ctx, cnrID, treeID, node.ID, parentID, meta) + if err = c.moveNode(ctx, cnrID, treeID, node.ID, parentID, meta); err != nil { + return err + } + + return c.clearOutdatedVersionInfo(ctx, cnrID, treeID, node.ID) } if !errors.Is(err, layer.ErrNodeNotFound) { @@ -1093,6 +1097,18 @@ func (c *TreeClient) addVersion(ctx context.Context, cnrID cid.ID, treeID string return c.addNodeByPath(ctx, cnrID, treeID, path[:len(path)-1], meta) } +func (c *TreeClient) clearOutdatedVersionInfo(ctx context.Context, cnrID cid.ID, treeID string, nodeID uint64) error { + taggingNode, err := c.getTreeNode(ctx, cnrID, nodeID, isTagKV) + if err != nil { + return err + } + if taggingNode != nil { + return c.removeNode(ctx, cnrID, treeID, taggingNode.ID) + } + + return nil +} + func (c *TreeClient) getVersions(ctx context.Context, cnrID cid.ID, treeID, filepath string, onlyUnversioned bool) ([]*data.NodeVersion, error) { keysToReturn := []string{oidKV, isUnversionedKV, isDeleteMarkerKV, etagKV, sizeKV} path := pathFromName(filepath)