NBS: Create directory for store if it doesn't exist (#3028)

Fixes #2909
This commit is contained in:
cmasone-attic
2017-01-05 11:51:56 -08:00
committed by GitHub
parent 14c20ebdd7
commit 87b7bed513
2 changed files with 16 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import (
"crypto/rand"
"io/ioutil"
"os"
"path/filepath"
"sort"
"testing"
@@ -43,12 +44,22 @@ func (suite *BlockStoreSuite) SetupTest() {
func (suite *BlockStoreSuite) TearDownTest() {
suite.store.Close()
os.Remove(suite.dir)
os.RemoveAll(suite.dir)
}
func (suite *BlockStoreSuite) TestChunkStoreMkdir() {
newDir := filepath.Join(suite.dir, "newthing")
store := NewLocalStore(newDir, testMemTableSize)
c := chunks.NewChunk([]byte("abc"))
suite.store.Put(c)
suite.NotPanics(func() { store.UpdateRoot(c.Hash(), store.Root()) })
}
func (suite *BlockStoreSuite) TestChunkStorePut() {
input := []byte("abc")
c := chunks.NewChunk([]byte(input))
c := chunks.NewChunk(input)
suite.store.Put(c)
h := c.Hash()

View File

@@ -5,6 +5,7 @@
package nbs
import (
"os"
"sort"
"sync"
@@ -81,6 +82,8 @@ func newAWSStore(table, ns, bucket string, sess *session.Session, memTableSize u
}
func NewLocalStore(dir string, memTableSize uint64) *NomsBlockStore {
err := os.MkdirAll(dir, 0777)
d.PanicIfError(err)
return newNomsBlockStore(fileManifest{dir}, newFSTableSet(dir), memTableSize)
}