[#868] blobstor: initialize (de-)compressors in Init
Do not log in options constructors. Also failure to initialize compression module (possibly due to invalid options) is certainly an error deserving proper treatment. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
fa1dc31320
commit
cc377b34d2
4 changed files with 22 additions and 24 deletions
|
@ -781,6 +781,22 @@ func (b *blobovniczas) updateAndGet(p string, old *uint64) (blobovniczaWithIndex
|
|||
func (b *blobovniczas) init() error {
|
||||
b.log.Debug("initializing Blobovnicza's")
|
||||
|
||||
if b.compressionEnabled {
|
||||
zstdC, err := zstdCompressor()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create zstd compressor: %v", err)
|
||||
}
|
||||
zstdD, err := zstdDecompressor()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create zstd decompressor: %v", err)
|
||||
}
|
||||
b.compressor = zstdC
|
||||
b.decompressor = zstdD
|
||||
} else {
|
||||
b.compressor = noOpCompressor
|
||||
b.decompressor = noOpDecompressor
|
||||
}
|
||||
|
||||
return b.iterateBlobovniczas(func(p string, blz *blobovnicza.Blobovnicza) error {
|
||||
if err := blz.Init(); err != nil {
|
||||
return fmt.Errorf("could not initialize blobovnicza structure %s: %w", p, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue