[#645] Replace tagging when PutObject

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2022-08-10 04:04:26 +04:00 committed by Kirillov Denis
parent 1987f271f9
commit 8eb1afbcb8
2 changed files with 19 additions and 2 deletions

View file

@ -10,7 +10,8 @@ This document outlines major changes between releases.
- Improved wallet configuration via `.yaml` config and environment variables (#607) - Improved wallet configuration via `.yaml` config and environment variables (#607)
### Removed ### Removed
### Fixed ### 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 ### Updating from v0.23.0
1. Make sure configuration of wallet is valid. If you use: 1. Make sure configuration of wallet is valid. If you use:
1. environment variables: set `S3_GW_WALLET_PATH` instead of `S3_GW_WALLET`, 1. environment variables: set `S3_GW_WALLET_PATH` instead of `S3_GW_WALLET`,

View file

@ -1082,7 +1082,11 @@ func (c *TreeClient) addVersion(ctx context.Context, cnrID cid.ID, treeID string
return err 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) { 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) 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) { 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} keysToReturn := []string{oidKV, isUnversionedKV, isDeleteMarkerKV, etagKV, sizeKV}
path := pathFromName(filepath) path := pathFromName(filepath)