[#220] blobstor: Implement method to close blobovnicza tree

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
remotes/KirillovDenis/release/v0.21.1
Leonard Lyubich 2020-11-30 17:14:28 +03:00 committed by Alex Vanin
parent 34a259d5c0
commit 51ab6991d2
1 changed files with 22 additions and 0 deletions

View File

@ -596,6 +596,28 @@ func (b *blobovniczas) init() error {
})
}
// closes blobovnicza tree.
func (b *blobovniczas) close() error {
b.opened.Purge()
b.activeMtx.Lock()
for p, v := range b.active {
if err := v.blz.Close(); err != nil {
b.log.Debug("could not close active blobovnicza",
zap.String("path", p),
zap.String("error", err.Error()),
)
}
delete(b.active, p)
}
b.activeMtx.Unlock()
return nil
}
// opens and returns blobovnicza with path p.
//
// If blobovnicza is already opened and cached, instance from cache is returned w/o changes.