forked from TrueCloudLab/frostfs-node
[#264] transformer: Finalize parent header once
In previous implementation parent object header finalized twice in size limiter + formatter. On the one hand, this added redundant action, on the other hand, it could provoke a difference in the headers of the linking and the last part. Change formatter to finalize parent header if it does not container the signature. Change size limiter to reuse parent header after last child finalization in linking child. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
edef9463d7
commit
ec21040542
3 changed files with 36 additions and 7 deletions
|
@ -69,9 +69,12 @@ func (f *formatter) Close() (*AccessIdentifiers, error) {
|
|||
f.obj.SetSessionToken(f.prm.SessionToken)
|
||||
f.obj.SetCreationEpoch(curEpoch)
|
||||
|
||||
var parID *objectSDK.ID
|
||||
var (
|
||||
parID *objectSDK.ID
|
||||
parHdr *objectSDK.Object
|
||||
)
|
||||
|
||||
if par := f.obj.Parent(); par != nil {
|
||||
if par := f.obj.Parent(); par != nil && par.Signature() == nil {
|
||||
rawPar := objectSDK.NewRawFromV2(par.ToV2())
|
||||
|
||||
rawPar.SetSessionToken(f.prm.SessionToken)
|
||||
|
@ -82,8 +85,9 @@ func (f *formatter) Close() (*AccessIdentifiers, error) {
|
|||
}
|
||||
|
||||
parID = rawPar.ID()
|
||||
parHdr = rawPar.Object()
|
||||
|
||||
f.obj.SetParent(rawPar.Object())
|
||||
f.obj.SetParent(parHdr)
|
||||
}
|
||||
|
||||
if err := objectSDK.SetIDWithSignature(f.prm.Key, f.obj.SDK()); err != nil {
|
||||
|
@ -100,5 +104,6 @@ func (f *formatter) Close() (*AccessIdentifiers, error) {
|
|||
|
||||
return new(AccessIdentifiers).
|
||||
WithSelfID(f.obj.ID()).
|
||||
WithParentID(parID), nil
|
||||
WithParentID(parID).
|
||||
WithParent(parHdr), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue