mirror of
https://github.com/taigrr/bitcask
synced 2025-01-18 04:03:17 -08:00
Fixed handling of missing config.json from cli behavior
This commit is contained in:
parent
1ba9ca46e3
commit
5d1dd6657a
13
bitcask.go
13
bitcask.go
@ -11,8 +11,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/gofrs/flock"
|
|
||||||
"github.com/derekparker/trie"
|
"github.com/derekparker/trie"
|
||||||
|
"github.com/gofrs/flock"
|
||||||
|
|
||||||
"github.com/prologic/bitcask/internal"
|
"github.com/prologic/bitcask/internal"
|
||||||
)
|
)
|
||||||
@ -430,18 +430,23 @@ func (b *Bitcask) Merge() error {
|
|||||||
// Options can be provided with the `WithXXX` functions that provide
|
// Options can be provided with the `WithXXX` functions that provide
|
||||||
// configuration options as functions.
|
// configuration options as functions.
|
||||||
func Open(path string, options ...Option) (*Bitcask, error) {
|
func Open(path string, options ...Option) (*Bitcask, error) {
|
||||||
|
var (
|
||||||
|
cfg *config
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
if err := os.MkdirAll(path, 0755); err != nil {
|
if err := os.MkdirAll(path, 0755); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
config, err := getConfig(path)
|
cfg, err = getConfig(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
cfg = newDefaultConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
bitcask := &Bitcask{
|
bitcask := &Bitcask{
|
||||||
Flock: flock.New(filepath.Join(path, "lock")),
|
Flock: flock.New(filepath.Join(path, "lock")),
|
||||||
config: config,
|
config: cfg,
|
||||||
options: options,
|
options: options,
|
||||||
path: path,
|
path: path,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user