forked from TrueCloudLab/frostfs-node
[#1319] services/object: Store payload directly in distributedTarget
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
9da7df4d42
commit
4ea03c01b5
1 changed files with 3 additions and 15 deletions
|
@ -22,7 +22,7 @@ type distributedTarget struct {
|
|||
|
||||
obj *objectSDK.Object
|
||||
|
||||
chunks [][]byte
|
||||
payload []byte
|
||||
|
||||
nodeTargetInitializer func(nodeDesc) transformer.ObjectTarget
|
||||
|
||||
|
@ -107,25 +107,13 @@ func (t *distributedTarget) WriteHeader(obj *objectSDK.Object) error {
|
|||
}
|
||||
|
||||
func (t *distributedTarget) Write(p []byte) (n int, err error) {
|
||||
t.chunks = append(t.chunks, p)
|
||||
t.payload = append(t.payload, p...)
|
||||
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func (t *distributedTarget) Close() (*transformer.AccessIdentifiers, error) {
|
||||
sz := 0
|
||||
|
||||
for i := range t.chunks {
|
||||
sz += len(t.chunks[i])
|
||||
}
|
||||
|
||||
payload := make([]byte, 0, sz)
|
||||
|
||||
for i := range t.chunks {
|
||||
payload = append(payload, t.chunks[i]...)
|
||||
}
|
||||
|
||||
t.obj.SetPayload(payload)
|
||||
t.obj.SetPayload(t.payload)
|
||||
|
||||
if err := t.fmt.ValidateContent(t.obj); err != nil {
|
||||
return nil, fmt.Errorf("(%T) could not validate payload content: %w", t, err)
|
||||
|
|
Loading…
Reference in a new issue