forked from TrueCloudLab/frostfs-node
[#1559] local_object_storage: Provide readOnly flag to Open
We should be able to reopen storage in readonly in runtime. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
e38b0aa4ba
commit
1e786233bf
20 changed files with 70 additions and 49 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
// Open boltDB instance for metabase.
|
||||
func (db *DB) Open() error {
|
||||
func (db *DB) Open(readOnly bool) error {
|
||||
err := util.MkdirAllX(filepath.Dir(db.info.Path), db.info.Permission)
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't create dir %s for metabase: %w", db.info.Path, err)
|
||||
|
@ -18,6 +18,11 @@ func (db *DB) Open() error {
|
|||
|
||||
db.log.Debug("created directory for Metabase", zap.String("path", db.info.Path))
|
||||
|
||||
if db.boltOptions == nil {
|
||||
db.boltOptions = bbolt.DefaultOptions
|
||||
}
|
||||
db.boltOptions.ReadOnly = readOnly
|
||||
|
||||
db.boltDB, err = bbolt.Open(db.info.Path, db.info.Permission, db.boltOptions)
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't open boltDB database: %w", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue