Merge pull request #47 from chenchun/fix_boltdb
Create dir first before opening data file of boltdb
This commit is contained in:
commit
b1d5d7edeb
1 changed files with 6 additions and 0 deletions
|
@ -4,6 +4,8 @@ import (
|
|||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
|
@ -43,6 +45,10 @@ func New(endpoints []string, options *store.Config) (store.Store, error) {
|
|||
return nil, ErrBoltBucketOptionMissing
|
||||
}
|
||||
|
||||
dir, _ := filepath.Split(endpoints[0])
|
||||
if err := os.MkdirAll(dir, 0750); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db, err := bolt.Open(endpoints[0], 0644, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Add table
Reference in a new issue