forked from TrueCloudLab/frostfs-s3-gw
[#451] Handle lock objects using tree service
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
bc000f1bc4
commit
dd534e8738
23 changed files with 488 additions and 520 deletions
|
@ -220,18 +220,15 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Object
|
|||
zap.Error(err))
|
||||
}
|
||||
|
||||
if p.Lock != nil {
|
||||
objInfo := &data.ObjectInfo{ID: *id, Name: p.Object}
|
||||
p.Lock.Objects = append(p.Lock.Objects, *id)
|
||||
if p.Lock.LegalHold {
|
||||
if err = n.putLockObject(ctx, p.BktInfo, objInfo.LegalHoldObject(), p.Lock); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if p.Lock != nil && (p.Lock.Retention != nil || p.Lock.LegalHold != nil) {
|
||||
objVersion := &ObjectVersion{
|
||||
BktInfo: p.BktInfo,
|
||||
ObjectName: p.Object,
|
||||
VersionID: id.EncodeToString(),
|
||||
}
|
||||
if !p.Lock.Until.IsZero() {
|
||||
if err = n.putLockObject(ctx, p.BktInfo, objInfo.RetentionObject(), p.Lock); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = n.PutLockInfo(ctx, objVersion, p.Lock); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,21 +263,6 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Object
|
|||
return objInfo, nil
|
||||
}
|
||||
|
||||
func (n *layer) putLockObject(ctx context.Context, bktInfo *data.BucketInfo, objName string, lock *data.ObjectLock) error {
|
||||
ps := &PutSystemObjectParams{
|
||||
BktInfo: bktInfo,
|
||||
ObjName: objName,
|
||||
Lock: lock,
|
||||
Metadata: make(map[string]string),
|
||||
}
|
||||
|
||||
if _, err := n.PutSystemObject(ctx, ps); err != nil {
|
||||
return fmt.Errorf("coudln't add lock for '%s': %w", objName, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *layer) headLastVersionIfNotDeleted(ctx context.Context, bkt *data.BucketInfo, objectName string) (*data.ObjectInfo, error) {
|
||||
if addr := n.namesCache.Get(bkt.Name + "/" + objectName); addr != nil {
|
||||
if headInfo := n.objCache.Get(*addr); headInfo != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue