[#1693] storage: Replace conditional panics with asserts
Change-Id: I9d8ccde3c71fca716856c7bfc53da20ee0542f20 Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
parent
a285d8924f
commit
fc6abe30b8
4 changed files with 17 additions and 26 deletions
|
@ -2,6 +2,8 @@ package fstree
|
|||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/assert"
|
||||
)
|
||||
|
||||
// FileCounter used to count files in FSTree. The implementation must be thread-safe.
|
||||
|
@ -52,16 +54,11 @@ func (c *SimpleCounter) Dec(size uint64) {
|
|||
c.mtx.Lock()
|
||||
defer c.mtx.Unlock()
|
||||
|
||||
if c.count > 0 {
|
||||
c.count--
|
||||
} else {
|
||||
panic("fstree.SimpleCounter: invalid count")
|
||||
}
|
||||
if c.size >= size {
|
||||
c.size -= size
|
||||
} else {
|
||||
panic("fstree.SimpleCounter: invalid size")
|
||||
}
|
||||
assert.True(c.count > 0, "fstree.SimpleCounter: invalid count")
|
||||
c.count--
|
||||
|
||||
assert.True(c.size >= size, "fstree.SimpleCounter: invalid size")
|
||||
c.size -= size
|
||||
}
|
||||
|
||||
func (c *SimpleCounter) CountSize() (uint64, uint64) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue