forked from TrueCloudLab/frostfs-s3-gw
[#577] Add IsDeleteMarker() to NodeVersion
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
2a933f48be
commit
f66e4a77cd
7 changed files with 12 additions and 8 deletions
|
@ -20,6 +20,10 @@ type NodeVersion struct {
|
||||||
IsUnversioned bool
|
IsUnversioned bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v NodeVersion) IsDeleteMarker() bool {
|
||||||
|
return v.DeleteMarker != nil
|
||||||
|
}
|
||||||
|
|
||||||
// DeleteMarkerInfo is used to save object info if node in the tree service is delete marker.
|
// DeleteMarkerInfo is used to save object info if node in the tree service is delete marker.
|
||||||
// We need this information because the "delete marker" object is no longer stored in NeoFS.
|
// We need this information because the "delete marker" object is no longer stored in NeoFS.
|
||||||
type DeleteMarkerInfo struct {
|
type DeleteMarkerInfo struct {
|
||||||
|
|
|
@ -122,7 +122,7 @@ func writeAttributesHeaders(h http.Header, info *data.ExtendedObjectInfo, isBuck
|
||||||
h.Set(api.AmzVersionID, info.Version())
|
h.Set(api.AmzVersionID, info.Version())
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.NodeVersion.DeleteMarker != nil {
|
if info.NodeVersion.IsDeleteMarker() {
|
||||||
h.Set(api.AmzDeleteMarker, strconv.FormatBool(true))
|
h.Set(api.AmzDeleteMarker, strconv.FormatBool(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -556,7 +556,7 @@ func (n *layer) getNodeVersionToDelete(ctx context.Context, bkt *data.BucketInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *layer) removeOldVersion(ctx context.Context, bkt *data.BucketInfo, nodeVersion *data.NodeVersion, obj *VersionedObject) (string, error) {
|
func (n *layer) removeOldVersion(ctx context.Context, bkt *data.BucketInfo, nodeVersion *data.NodeVersion, obj *VersionedObject) (string, error) {
|
||||||
if nodeVersion.DeleteMarker != nil {
|
if nodeVersion.IsDeleteMarker() {
|
||||||
return obj.VersionID, nil
|
return obj.VersionID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ func (n *layer) headLastVersionIfNotDeleted(ctx context.Context, bkt *data.Bucke
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.DeleteMarker != nil {
|
if node.IsDeleteMarker() {
|
||||||
return nil, apiErrors.GetAPIError(apiErrors.ErrNoSuchKey)
|
return nil, apiErrors.GetAPIError(apiErrors.ErrNoSuchKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ func (n *layer) getAllObjectsVersions(ctx context.Context, bkt *data.BucketInfo,
|
||||||
for _, nodeVersion := range nodeVersions {
|
for _, nodeVersion := range nodeVersions {
|
||||||
oi := &data.ObjectInfo{}
|
oi := &data.ObjectInfo{}
|
||||||
|
|
||||||
if nodeVersion.DeleteMarker != nil { // delete marker does not match any object in NeoFS
|
if nodeVersion.IsDeleteMarker() { // delete marker does not match any object in NeoFS
|
||||||
oi.ID = nodeVersion.OID
|
oi.ID = nodeVersion.OID
|
||||||
oi.Name = nodeVersion.FilePath
|
oi.Name = nodeVersion.FilePath
|
||||||
oi.Owner = nodeVersion.DeleteMarker.Owner
|
oi.Owner = nodeVersion.DeleteMarker.Owner
|
||||||
|
|
|
@ -163,7 +163,7 @@ func (n *layer) getNodeVersion(ctx context.Context, objVersion *ObjectVersion) (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil && version.DeleteMarker != nil && !objVersion.NoErrorOnDeleteMarker || errorsStd.Is(err, ErrNodeNotFound) {
|
if err == nil && version.IsDeleteMarker() && !objVersion.NoErrorOnDeleteMarker || errorsStd.Is(err, ErrNodeNotFound) {
|
||||||
return nil, errors.GetAPIError(errors.ErrNoSuchKey)
|
return nil, errors.GetAPIError(errors.ErrNoSuchKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ func triageVersions(objVersions []*data.ExtendedObjectInfo) ([]*data.ExtendedObj
|
||||||
var resDelMarkVersions []*data.ExtendedObjectInfo
|
var resDelMarkVersions []*data.ExtendedObjectInfo
|
||||||
|
|
||||||
for _, version := range objVersions {
|
for _, version := range objVersions {
|
||||||
if version.NodeVersion.DeleteMarker != nil {
|
if version.NodeVersion.IsDeleteMarker() {
|
||||||
resDelMarkVersions = append(resDelMarkVersions, version)
|
resDelMarkVersions = append(resDelMarkVersions, version)
|
||||||
} else {
|
} else {
|
||||||
resVersion = append(resVersion, version)
|
resVersion = append(resVersion, version)
|
||||||
|
|
|
@ -747,7 +747,7 @@ func (c *TreeClient) getSubTreeVersions(ctx context.Context, cnrID cid.ID, nodeI
|
||||||
|
|
||||||
result := make([]*data.NodeVersion, 0, len(versions)) // consider use len(subTree)
|
result := make([]*data.NodeVersion, 0, len(versions)) // consider use len(subTree)
|
||||||
for _, version := range versions {
|
for _, version := range versions {
|
||||||
if latestOnly && version[0].DeleteMarker != nil {
|
if latestOnly && version[0].IsDeleteMarker() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
result = append(result, version...)
|
result = append(result, version...)
|
||||||
|
@ -1066,7 +1066,7 @@ func (c *TreeClient) addVersion(ctx context.Context, cnrID cid.ID, treeID string
|
||||||
meta[etagKV] = version.ETag
|
meta[etagKV] = version.ETag
|
||||||
}
|
}
|
||||||
|
|
||||||
if version.DeleteMarker != nil {
|
if version.IsDeleteMarker() {
|
||||||
meta[isDeleteMarkerKV] = "true"
|
meta[isDeleteMarkerKV] = "true"
|
||||||
meta[ownerKV] = version.DeleteMarker.Owner.EncodeToString()
|
meta[ownerKV] = version.DeleteMarker.Owner.EncodeToString()
|
||||||
meta[createdKV] = strconv.FormatInt(version.DeleteMarker.Created.UTC().UnixMilli(), 10)
|
meta[createdKV] = strconv.FormatInt(version.DeleteMarker.Created.UTC().UnixMilli(), 10)
|
||||||
|
|
Loading…
Reference in a new issue