mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-09 10:38:10 -06:00
NBS: Create directory for store if it doesn't exist (#3028)
Fixes #2909
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user