[#2175] blobovniczatree: Close all non-active blobovniczas

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2022-12-26 14:47:14 +03:00 committed by Anton Nikiforov
parent c1cf418956
commit 0ace28e43d

View file

@ -98,7 +98,11 @@ func NewBlobovniczaTree(opts ...Option) (blz *Blobovniczas) {
}
cache, err := simplelru.NewLRU(blz.openedCacheSize, func(key interface{}, value interface{}) {
if _, ok := blz.active[filepath.Dir(key.(string))]; ok {
p := key.(string)
lvlPath := filepath.Dir(p)
if b, ok := blz.active[lvlPath]; ok && b.ind == u64FromHexString(filepath.Base(p)) {
// This branch is taken if we have recently updated active blobovnicza and remove
// it from opened cache.
return
} else if err := value.(*blobovnicza.Blobovnicza).Close(); err != nil {
blz.log.Error("could not close Blobovnicza",