[#227] transformer: Do not inherit attribute in generated objects
In previous implementation child objects inherited parent attributes after split-transformation, which was redundant. From now attributes are not inherited. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
5470d94416
commit
b8e8e1e80d
1 changed files with 26 additions and 7 deletions
|
@ -29,6 +29,8 @@ type payloadSizeLimiter struct {
|
||||||
chunkWriter io.Writer
|
chunkWriter io.Writer
|
||||||
|
|
||||||
splitID *objectSDK.SplitID
|
splitID *objectSDK.SplitID
|
||||||
|
|
||||||
|
parAttrs []*objectSDK.Attribute
|
||||||
}
|
}
|
||||||
|
|
||||||
type payloadChecksumHasher struct {
|
type payloadChecksumHasher struct {
|
||||||
|
@ -78,10 +80,7 @@ func (s *payloadSizeLimiter) initialize() {
|
||||||
if ln := len(s.previous); ln > 0 {
|
if ln := len(s.previous); ln > 0 {
|
||||||
// initialize parent object once (after 1st object)
|
// initialize parent object once (after 1st object)
|
||||||
if ln == 1 {
|
if ln == 1 {
|
||||||
s.parent = s.current
|
s.detachParent()
|
||||||
s.current = fromObject(s.parent)
|
|
||||||
s.parent.ResetRelations()
|
|
||||||
s.parentHashers = s.currentHashers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set previous object to the last previous identifier
|
// set previous object to the last previous identifier
|
||||||
|
@ -228,9 +227,7 @@ func (s *payloadSizeLimiter) writeChunk(chunk []byte) error {
|
||||||
// statement is true if the previous write of bytes reached exactly the boundary.
|
// statement is true if the previous write of bytes reached exactly the boundary.
|
||||||
if s.written > 0 && s.written%s.maxSize == 0 {
|
if s.written > 0 && s.written%s.maxSize == 0 {
|
||||||
if s.written == s.maxSize {
|
if s.written == s.maxSize {
|
||||||
// initialize split header with split ID on first object in chain
|
s.prepareFirstChild()
|
||||||
s.current.InitRelations()
|
|
||||||
s.current.SetSplitID(s.splitID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to release current object
|
// we need to release current object
|
||||||
|
@ -267,3 +264,25 @@ func (s *payloadSizeLimiter) writeChunk(chunk []byte) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *payloadSizeLimiter) prepareFirstChild() {
|
||||||
|
// initialize split header with split ID on first object in chain
|
||||||
|
s.current.InitRelations()
|
||||||
|
s.current.SetSplitID(s.splitID)
|
||||||
|
|
||||||
|
// cut source attributes
|
||||||
|
s.parAttrs = s.current.Attributes()
|
||||||
|
s.current.SetAttributes()
|
||||||
|
|
||||||
|
// attributes will be added to parent in detachParent
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *payloadSizeLimiter) detachParent() {
|
||||||
|
s.parent = s.current
|
||||||
|
s.current = fromObject(s.parent)
|
||||||
|
s.parent.ResetRelations()
|
||||||
|
s.parentHashers = s.currentHashers
|
||||||
|
|
||||||
|
// return source attributes
|
||||||
|
s.parent.SetAttributes(s.parAttrs...)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue