huh
Brian Tiger Chow committed
Jan 13, 2015 at 17:34 UTC
6ec20b35749c3f9389b8d042b05616a4a38bbb36
4 files changed
+11
-6
cmd/ipfs/main.go
+1
-6
@@ -444,12 +444,7 @@ func getConfigRoot(req cmds.Request) (string, error) {
444
}
445
446
func loadConfig(path string) (*config.Config, error) {
447
- r := fsrepo.At(path)
448
- if err := r.Open(); err != nil {
449
- return nil, err
450
- }
451
- defer r.Close()
452
- return r.Config(), nil
447
+ return fsrepo.ConfigAt(path)
448
}
449
450
// startProfiling begins CPU profiling and returns a `stop` function to be
cmd/ipfs/tour.go
+1
@@ -188,6 +188,7 @@ func tourGet(id tour.ID) (*tour.Topic, error) {
188
189
// TODO share func
190
func writeConfig(path string, cfg *config.Config) error {
191
+ // NB: This needs to run on the daemon.
192
r := fsrepo.At(path)
193
if err := r.Open(); err != nil {
194
return err
repo/fsrepo/fsrepo.go
+8
@@ -51,6 +51,14 @@ func At(repoPath string) *FSRepo {
51
}
52
}
53
54
+func ConfigAt(repoPath string) (*config.Config, error) {
55
+ configFilename, err := config.Filename(repoPath)
56
+ if err != nil {
57
+ return nil, err
58
+ }
59
+ return load(configFilename)
60
+}
61
+
62
// Init initializes a new FSRepo at the given path with the provided config.
63
func Init(path string, conf *config.Config) error {
64
openerCounter.Lock() // lock must be held to ensure atomicity (prevent Removal)
repo/fsrepo/serialize.go
+1
@@ -69,6 +69,7 @@ func load(filename string) (*config.Config, error) {
69
}
70
71
// tilde expansion on datastore path
72
+ // TODO why is this here??
73
cfg.Datastore.Path, err = util.TildeExpansion(cfg.Datastore.Path)
74
if err != nil {
75
return nil, err