From 51ab6991d20c3a75b979cd0e0cb61bb0acc9e7e5 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 30 Nov 2020 17:14:28 +0300 Subject: [PATCH] [#220] blobstor: Implement method to close blobovnicza tree Signed-off-by: Leonard Lyubich --- .../blobstor/blobovnicza.go | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/local_object_storage/blobstor/blobovnicza.go b/pkg/local_object_storage/blobstor/blobovnicza.go index daeb5ce28..039c89358 100644 --- a/pkg/local_object_storage/blobstor/blobovnicza.go +++ b/pkg/local_object_storage/blobstor/blobovnicza.go @@ -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.