@cryptotaxi247 / kubo / commits / a79907b7c

repo: properly init Datastore config, and leave it be

We didn't previously initialize the Datastore config section. The respective function exists, but was dead code up until now. This lead to weird decisions like the GC code deciding on defaults, and writing these to the config file. Don't want GC to touch the config. License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>

Lars Gierth committed Apr 7, 2016 at 17:01 UTC a79907b7c150c3ab37ab68e8a944082f1fcd1572
2 files changed +9 -4
core/corerepo/gc.go
-1
@@ -119,7 +119,6 @@ func PeriodicGC(ctx context.Context, node *core.IpfsNode) error {
119 }
120
121 if cfg.Datastore.GCPeriod == "" {
122 - node.Repo.SetConfigKey("Datastore.GCPeriod", "1h")
122 cfg.Datastore.GCPeriod = "1h"
123 }
124
repo/config/init.go
+9 -3
@@ -21,6 +21,11 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
21 return nil, err
22 }
23
24 + datastore, err := datastoreConfig()
25 + if err != nil {
26 + return nil, err
27 + }
28 +
29 conf := &Config{
30
31 // setup the node's default addresses.
@@ -35,6 +40,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
40 Gateway: "/ip4/127.0.0.1/tcp/8080",
41 },
42
43 + Datastore: datastore,
44 Bootstrap: BootstrapPeerStrings(bootstrapPeers),
45 Identity: identity,
46 Discovery: Discovery{MDNS{
@@ -62,12 +68,12 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
68 return conf, nil
69 }
70
65 -func datastoreConfig() (*Datastore, error) {
71 +func datastoreConfig() (Datastore, error) {
72 dspath, err := DataStorePath("")
73 if err != nil {
68 - return nil, err
74 + return Datastore{}, err
75 }
70 - return &Datastore{
76 + return Datastore{
77 Path: dspath,
78 Type: "leveldb",
79 StorageMax: "10GB",