docker / libkv

Distributed key/value store abstraction library
Apache License 2.0
853 stars 205 forks source link

store/boltdb: Allow paths with no slash at the beginning #161

Open vishen opened 7 years ago

vishen commented 7 years ago

The following was not working for me because of the way libkv handles the path for BoltDB

kv, err := libkv.NewStore(
    store.BOLTDB,
    []string{"__boltdbtest"},
    &store.Config{
        Bucket: "boltDBTest",
    },
)

I would get the following error because when libkv attempts to create the BoltDB path: mkdir : no such file or directory - It uses https://godoc.org/path/filepath#Split which can return an empty string for dir.

This PR checks if the dir is not an empty string before calling os.MkdirAll(dir, 0750).

GordonTheTurtle commented 7 years ago

Please sign your commits following these rules: https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work The easiest way to do this is to amend the last commit:

$ git clone -b "master" git@github.com:vishen/libkv.git somewhere
$ cd somewhere
$ git commit --amend -s --no-edit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.