forked from TrueCloudLab/frostfs-node
[#1178] shard: Check metabase existence before read shard ID
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
b9d6c9d10c
commit
76cf7a051b
1 changed files with 5 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr"
|
||||
metamode "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||
|
@ -25,6 +26,10 @@ func (db *DB) GetShardID(mode metamode.Mode) ([]byte, error) {
|
|||
defer db.modeMtx.Unlock()
|
||||
db.mode = mode
|
||||
|
||||
if _, err := os.Stat(db.info.Path); errors.Is(err, os.ErrNotExist) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if err := db.openDB(mode); err != nil {
|
||||
return nil, fmt.Errorf("failed to open metabase: %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue