forked from TrueCloudLab/frostfs-s3-gw
[#429] Refactor TreeService for notif,cors,settings
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
8eff857e41
commit
ab5c44ac14
5 changed files with 88 additions and 127 deletions
|
@ -24,11 +24,6 @@ func (n *layer) PutBucketNotificationConfiguration(ctx context.Context, p *PutBu
|
|||
return fmt.Errorf("marshal notify configuration: %w", err)
|
||||
}
|
||||
|
||||
ids, nodeIds, err := n.treeService.GetNotificationConfigurationNodes(ctx, &p.BktInfo.CID, false)
|
||||
if err != nil && !errorsStd.Is(err, ErrNodeNotFound) {
|
||||
return err
|
||||
}
|
||||
|
||||
sysName := p.BktInfo.NotificationConfigurationObjectName()
|
||||
|
||||
s := &PutSystemObjectParams{
|
||||
|
@ -44,19 +39,17 @@ func (n *layer) PutBucketNotificationConfiguration(ctx context.Context, p *PutBu
|
|||
return err
|
||||
}
|
||||
|
||||
if err = n.treeService.PutNotificationConfigurationNode(ctx, &p.BktInfo.CID, &obj.ID); err != nil {
|
||||
objIDToDelete, err := n.treeService.PutNotificationConfigurationNode(ctx, &p.BktInfo.CID, &obj.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := 0; i < len(ids); i++ {
|
||||
if err = n.objectDelete(ctx, p.BktInfo, *ids[i]); err != nil {
|
||||
if objIDToDelete != nil {
|
||||
if err = n.objectDelete(ctx, p.BktInfo, *objIDToDelete); err != nil {
|
||||
n.log.Error("couldn't delete notification configuration object", zap.Error(err),
|
||||
zap.String("cnrID", p.BktInfo.CID.EncodeToString()),
|
||||
zap.String("bucket name", p.BktInfo.Name),
|
||||
zap.String("objID", ids[i].EncodeToString()))
|
||||
}
|
||||
if err = n.treeService.DeleteNotificationConfigurationNode(ctx, &p.BktInfo.CID, nodeIds[i]); err != nil {
|
||||
return err
|
||||
zap.String("objID", objIDToDelete.EncodeToString()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,15 +67,15 @@ func (n *layer) GetBucketNotificationConfiguration(ctx context.Context, bktInfo
|
|||
return conf, nil
|
||||
}
|
||||
|
||||
ids, _, err := n.treeService.GetNotificationConfigurationNodes(ctx, &bktInfo.CID, true)
|
||||
objId, err := n.treeService.GetNotificationConfigurationNode(ctx, &bktInfo.CID)
|
||||
if err != nil && !errorsStd.Is(err, ErrNodeNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
conf := &data.NotificationConfiguration{}
|
||||
|
||||
if len(ids) != 0 {
|
||||
obj, err := n.objectGet(ctx, bktInfo, *ids[0])
|
||||
if objId != nil {
|
||||
obj, err := n.objectGet(ctx, bktInfo, *objId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue