mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
Address p.r. feedback
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
This commit is contained in:
parent
6438fc74f9
commit
1f8723d01d
@ -76,7 +76,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
|
||||
return conf, nil
|
||||
}
|
||||
|
||||
// DatastoreConfig is an internal function exported to aid in testing.
|
||||
// DefaultDatastoreConfig is an internal function exported to aid in testing.
|
||||
func DefaultDatastoreConfig() Datastore {
|
||||
return Datastore{
|
||||
StorageMax: "10GB",
|
||||
|
||||
@ -87,7 +87,7 @@ func TestDefaultDatastoreConfig(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expected := `{"mounts":[{"mountpoint":{"string":"/blocks"},"path":"blocks","shardFunc":"/repo/flatfs/shard/v1/next-to-last/2","type":"flatfs"},{"mountpoint":{"string":"/"},"path":"datastore","type":"levelds"}],"type":"mount"}`
|
||||
expected := `{"mounts":[{"mountpoint":"/blocks","path":"blocks","shardFunc":"/repo/flatfs/shard/v1/next-to-last/2","type":"flatfs"},{"mountpoint":"/","path":"datastore","type":"levelds"}],"type":"mount"}`
|
||||
if dsc.DiskSpec().String() != expected {
|
||||
t.Errorf("expected '%s' got '%s' as DiskId", expected, dsc.DiskSpec().String())
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ func (c *mountDatastoreConfig) DiskSpec() DiskSpec {
|
||||
if c == nil {
|
||||
c = make(map[string]interface{})
|
||||
}
|
||||
c["mountpoint"] = m.prefix
|
||||
c["mountpoint"] = m.prefix.String()
|
||||
mounts[i] = c
|
||||
}
|
||||
cfg["mounts"] = mounts
|
||||
@ -247,6 +247,7 @@ type memDatastoreConfig struct {
|
||||
cfg map[string]interface{}
|
||||
}
|
||||
|
||||
// MemDatastoreConfig returns a memory DatastoreConfig from a spec
|
||||
func MemDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) {
|
||||
return &memDatastoreConfig{params}, nil
|
||||
}
|
||||
|
||||
@ -62,6 +62,8 @@ func (err NoRepoError) Error() string {
|
||||
const apiFile = "api"
|
||||
const swarmKeyFile = "swarm.key"
|
||||
|
||||
const specFn = "datastore_spec"
|
||||
|
||||
var (
|
||||
|
||||
// packageLock must be held to while performing any operation that modifies an
|
||||
@ -245,7 +247,7 @@ func initConfig(path string, conf *config.Config) error {
|
||||
}
|
||||
|
||||
func initSpec(path string, conf map[string]interface{}) error {
|
||||
fn, err := config.Path(path, SpecFn)
|
||||
fn, err := config.Path(path, specFn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -415,10 +417,8 @@ func (r *FSRepo) openDatastore() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var SpecFn = "datastore_spec"
|
||||
|
||||
func (r *FSRepo) readSpec() (string, error) {
|
||||
fn, err := config.Path(r.path, SpecFn)
|
||||
fn, err := config.Path(r.path, specFn)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user