forked from TrueCloudLab/frostfs-api-go
[#164] sdk/object: Implement method to reset relation fields
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f3bddc2ba5
commit
2a2e4d8577
3 changed files with 21 additions and 0 deletions
|
@ -143,3 +143,8 @@ func (o *RawObject) CutPayload() *RawObject {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ResetRelations removes all fields of links with other objects.
|
||||
func (o *RawObject) ResetRelations() {
|
||||
o.resetRelations()
|
||||
}
|
||||
|
|
|
@ -265,3 +265,13 @@ func TestRawObject_SetParentID(t *testing.T) {
|
|||
|
||||
require.Equal(t, id, obj.GetParentID())
|
||||
}
|
||||
|
||||
func TestRawObject_ResetRelations(t *testing.T) {
|
||||
obj := NewRaw()
|
||||
|
||||
obj.SetPreviousID(randID(t))
|
||||
|
||||
obj.ResetRelations()
|
||||
|
||||
require.Nil(t, obj.GetPreviousID())
|
||||
}
|
||||
|
|
|
@ -296,6 +296,12 @@ func (o *rwObject) setParent(v *Object) {
|
|||
})
|
||||
}
|
||||
|
||||
func (o *rwObject) resetRelations() {
|
||||
o.setHeaderField(func(h *object.Header) {
|
||||
h.SetSplit(nil)
|
||||
})
|
||||
}
|
||||
|
||||
// GetSessionToken returns token of the session
|
||||
// within which object was created.
|
||||
func (o *rwObject) GetSessionToken() *token.SessionToken {
|
||||
|
|
Loading…
Reference in a new issue