[#102] Set split header in left object

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-10-20 09:54:19 +03:00 committed by Alex Vanin
parent 4d2ff842a2
commit 9e08b41a6f

View file

@ -79,9 +79,6 @@ func (s *payloadSizeLimiter) initialize() {
s.parent.ResetRelations() s.parent.ResetRelations()
s.parentHashers = s.currentHashers s.parentHashers = s.currentHashers
s.current = fromObject(s.parent) s.current = fromObject(s.parent)
// initialize blank split header
s.current.InitRelations()
} }
// set previous object to the last previous identifier // set previous object to the last previous identifier
@ -220,6 +217,11 @@ func (s *payloadSizeLimiter) initializeLinking() {
func (s *payloadSizeLimiter) writeChunk(chunk []byte) error { 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 {
// initialize blank split header on first object in chain
s.current.InitRelations()
}
// we need to release current object // we need to release current object
if _, err := s.release(false); err != nil { if _, err := s.release(false); err != nil {
return errors.Wrap(err, "could not release object") return errors.Wrap(err, "could not release object")