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

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
carpawell/fix/multiple-cache-update-requests-FROST
Evgenii Stratonikov 2022-12-26 14:47:14 +03:00 committed by Anton Nikiforov
parent c1cf418956
commit 0ace28e43d
1 changed files with 5 additions and 1 deletions

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",