diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go index 0dc7ddf0f..550d9b605 100644 --- a/cmd/ipfs/main.go +++ b/cmd/ipfs/main.go @@ -444,12 +444,7 @@ func getConfigRoot(req cmds.Request) (string, error) { } func loadConfig(path string) (*config.Config, error) { - r := fsrepo.At(path) - if err := r.Open(); err != nil { - return nil, err - } - defer r.Close() - return r.Config(), nil + return fsrepo.ConfigAt(path) } // startProfiling begins CPU profiling and returns a `stop` function to be diff --git a/cmd/ipfs/tour.go b/cmd/ipfs/tour.go index b61cc50f7..168bacc9c 100644 --- a/cmd/ipfs/tour.go +++ b/cmd/ipfs/tour.go @@ -188,6 +188,7 @@ func tourGet(id tour.ID) (*tour.Topic, error) { // TODO share func func writeConfig(path string, cfg *config.Config) error { + // NB: This needs to run on the daemon. r := fsrepo.At(path) if err := r.Open(); err != nil { return err diff --git a/repo/fsrepo/fsrepo.go b/repo/fsrepo/fsrepo.go index c8cfd91d9..e73524073 100644 --- a/repo/fsrepo/fsrepo.go +++ b/repo/fsrepo/fsrepo.go @@ -51,6 +51,14 @@ func At(repoPath string) *FSRepo { } } +func ConfigAt(repoPath string) (*config.Config, error) { + configFilename, err := config.Filename(repoPath) + if err != nil { + return nil, err + } + return load(configFilename) +} + // Init initializes a new FSRepo at the given path with the provided config. func Init(path string, conf *config.Config) error { openerCounter.Lock() // lock must be held to ensure atomicity (prevent Removal) diff --git a/repo/fsrepo/serialize.go b/repo/fsrepo/serialize.go index dcbf4ccf1..559c04804 100644 --- a/repo/fsrepo/serialize.go +++ b/repo/fsrepo/serialize.go @@ -69,6 +69,7 @@ func load(filename string) (*config.Config, error) { } // tilde expansion on datastore path + // TODO why is this here?? cfg.Datastore.Path, err = util.TildeExpansion(cfg.Datastore.Path) if err != nil { return nil, err