1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 01:52:26 +08:00
This commit is contained in:
Brian Tiger Chow
2015-01-13 17:34:24 -08:00
parent 76202a9444
commit 6ec20b3574
4 changed files with 11 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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