forked from TrueCloudLab/frostfs-node
[#838] metabase: Resolve funlen linter
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
d30ab5f29e
commit
a478050639
1 changed files with 76 additions and 65 deletions
|
@ -139,9 +139,57 @@ func (db *DB) deleteGroup(tx *bbolt.Tx, addrs []oid.Address) (DeleteRes, error)
|
|||
for i := range addrs {
|
||||
r, err := db.delete(tx, addrs[i], refCounter, currEpoch)
|
||||
if err != nil {
|
||||
return DeleteRes{}, err // maybe log and continue?
|
||||
return DeleteRes{}, err
|
||||
}
|
||||
|
||||
applyDeleteSingleResult(r, &res, addrs, i)
|
||||
}
|
||||
|
||||
if err := db.updateCountersDelete(tx, res); err != nil {
|
||||
return DeleteRes{}, err
|
||||
}
|
||||
|
||||
for _, refNum := range refCounter {
|
||||
if refNum.cur == refNum.all {
|
||||
err := db.deleteObject(tx, refNum.obj, true)
|
||||
if err != nil {
|
||||
return DeleteRes{}, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (db *DB) updateCountersDelete(tx *bbolt.Tx, res DeleteRes) error {
|
||||
if res.rawRemoved > 0 {
|
||||
err := db.updateShardObjectCounter(tx, phy, res.rawRemoved, false)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not decrease phy object counter: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if res.availableRemoved > 0 {
|
||||
err := db.updateShardObjectCounter(tx, logical, res.availableRemoved, false)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not decrease logical object counter: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if res.userRemoved > 0 {
|
||||
err := db.updateShardObjectCounter(tx, user, res.userRemoved, false)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not decrease user object counter: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := db.updateContainerCounter(tx, res.removedByCnrID, false); err != nil {
|
||||
return fmt.Errorf("could not decrease container object counter: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func applyDeleteSingleResult(r deleteSingleResult, res *DeleteRes, addrs []oid.Address, i int) {
|
||||
if r.Removed {
|
||||
if v, ok := res.removedByCnrID[addrs[i].Container()]; ok {
|
||||
v.Phy++
|
||||
|
@ -182,43 +230,6 @@ func (db *DB) deleteGroup(tx *bbolt.Tx, addrs []oid.Address) (DeleteRes, error)
|
|||
|
||||
res.userRemoved++
|
||||
}
|
||||
}
|
||||
|
||||
if res.rawRemoved > 0 {
|
||||
err := db.updateShardObjectCounter(tx, phy, res.rawRemoved, false)
|
||||
if err != nil {
|
||||
return DeleteRes{}, fmt.Errorf("could not decrease phy object counter: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if res.availableRemoved > 0 {
|
||||
err := db.updateShardObjectCounter(tx, logical, res.availableRemoved, false)
|
||||
if err != nil {
|
||||
return DeleteRes{}, fmt.Errorf("could not decrease logical object counter: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if res.userRemoved > 0 {
|
||||
err := db.updateShardObjectCounter(tx, user, res.userRemoved, false)
|
||||
if err != nil {
|
||||
return DeleteRes{}, fmt.Errorf("could not decrease user object counter: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := db.updateContainerCounter(tx, res.removedByCnrID, false); err != nil {
|
||||
return DeleteRes{}, fmt.Errorf("could not decrease container object counter: %w", err)
|
||||
}
|
||||
|
||||
for _, refNum := range refCounter {
|
||||
if refNum.cur == refNum.all {
|
||||
err := db.deleteObject(tx, refNum.obj, true)
|
||||
if err != nil {
|
||||
return DeleteRes{}, err // maybe log and continue?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
type deleteSingleResult struct {
|
||||
|
|
Loading…
Reference in a new issue