frostfs-node/pkg/local_object_storage/blobstor/mode.go
Alex Vanin 20de74a505 Rename package name
Due to source code relocation from GitHub.

Signed-off-by: Alex Vanin <a.vanin@yadro.com>
2023-03-07 16:38:26 +03:00

34 lines
590 B
Go

package blobstor
import (
"fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
)
// SetMode sets the blobstor mode of operation.
func (b *BlobStor) SetMode(m mode.Mode) error {
b.modeMtx.Lock()
defer b.modeMtx.Unlock()
if b.mode == m {
return nil
}
if b.mode.ReadOnly() == m.ReadOnly() {
return nil
}
err := b.Close()
if err == nil {
if err = b.Open(m.ReadOnly()); err == nil {
err = b.Init()
}
}
if err != nil {
return fmt.Errorf("can't set blobstor mode (old=%s, new=%s): %w", b.mode, m, err)
}
b.mode = m
return nil
}