forked from TrueCloudLab/frostfs-s3-gw
[#709] Add expiration attribute for legal hold
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
7573fb77e2
commit
be4600988e
1 changed files with 27 additions and 16 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"encoding/xml"
|
||||
errorsStd "errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
|
@ -233,24 +234,34 @@ func (n *layer) PutBucketSettings(ctx context.Context, p *PutSettingsParams) err
|
|||
}
|
||||
|
||||
func (n *layer) attributesFromLock(ctx context.Context, lock *data.ObjectLock) ([][2]string, error) {
|
||||
if lock.Retention == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var (
|
||||
err error
|
||||
expEpoch uint64
|
||||
result [][2]string
|
||||
)
|
||||
|
||||
_, exp, err := n.neoFS.TimeToEpoch(ctx, lock.Retention.Until)
|
||||
if err != nil {
|
||||
if lock.Retention != nil {
|
||||
if _, expEpoch, err = n.neoFS.TimeToEpoch(ctx, lock.Retention.Until); err != nil {
|
||||
return nil, fmt.Errorf("fetch time to epoch: %w", err)
|
||||
}
|
||||
|
||||
result := [][2]string{
|
||||
{AttributeExpirationEpoch, strconv.FormatUint(exp, 10)},
|
||||
if lock.Retention.IsCompliance {
|
||||
result = append(result, [2]string{AttributeComplianceMode, "true"})
|
||||
}
|
||||
}
|
||||
|
||||
if lock.Retention.IsCompliance {
|
||||
attrCompliance := [2]string{
|
||||
AttributeComplianceMode, strconv.FormatBool(true),
|
||||
if lock.LegalHold != nil && lock.LegalHold.Enabled {
|
||||
// todo: (@KirillovDenis) reconsider this when NeoFS will support Legal Hold https://github.com/nspcc-dev/neofs-contract/issues/247
|
||||
// Currently lock object must have an expiration epoch.
|
||||
// Besides we need to override retention expiration epoch since legal hold cannot be deleted yet.
|
||||
expEpoch = math.MaxUint64
|
||||
}
|
||||
result = append(result, attrCompliance)
|
||||
|
||||
if expEpoch != 0 {
|
||||
result = append(result, [2]string{
|
||||
AttributeExpirationEpoch, strconv.FormatUint(expEpoch, 10),
|
||||
})
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue