From 25f00e1549850a030a05a3dd6d71b28cbb5cf256 Mon Sep 17 00:00:00 2001 From: Jonathan Pentecost Date: Fri, 5 May 2017 09:10:23 +0100 Subject: [PATCH] store/boltdb: Allow paths with no slash at the beginning Signed-off-by: Jonathan Pentecost --- store/boltdb/boltdb.go | 6 ++++-- store/boltdb/boltdb_test.go | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/store/boltdb/boltdb.go b/store/boltdb/boltdb.go index cdfd74f8..c86d478c 100644 --- a/store/boltdb/boltdb.go +++ b/store/boltdb/boltdb.go @@ -71,8 +71,10 @@ func New(endpoints []string, options *store.Config) (store.Store, error) { } dir, _ := filepath.Split(endpoints[0]) - if err = os.MkdirAll(dir, 0750); err != nil { - return nil, err + if dir != "" { + if err = os.MkdirAll(dir, 0750); err != nil { + return nil, err + } } if options.PersistConnection { diff --git a/store/boltdb/boltdb_test.go b/store/boltdb/boltdb_test.go index 3eb4e84b..96d0519d 100644 --- a/store/boltdb/boltdb_test.go +++ b/store/boltdb/boltdb_test.go @@ -134,7 +134,7 @@ func TestConcurrentConnection(t *testing.T) { _ = os.Remove("/tmp/__boltdbtest") } -func TestBoldDBStore(t *testing.T) { +func TestBoltDBStore(t *testing.T) { kv := makeBoltDBClient(t) testutils.RunTestCommon(t, kv) @@ -142,3 +142,16 @@ func TestBoldDBStore(t *testing.T) { _ = os.Remove("/tmp/not_exist_dir/__boltdbtest") } + +func TestRelativePathWithNoBeginningSlash(t *testing.T) { + + _, err := libkv.NewStore( + store.BOLTDB, + []string{"__boltdbtest"}, + &store.Config{ + Bucket: "boltDBTest", + }, + ) + + assert.NoError(t, err) +}