1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-03 21:08:17 +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) { func loadConfig(path string) (*config.Config, error) {
r := fsrepo.At(path) return fsrepo.ConfigAt(path)
if err := r.Open(); err != nil {
return nil, err
}
defer r.Close()
return r.Config(), nil
} }
// startProfiling begins CPU profiling and returns a `stop` function to be // 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 // TODO share func
func writeConfig(path string, cfg *config.Config) error { func writeConfig(path string, cfg *config.Config) error {
// NB: This needs to run on the daemon.
r := fsrepo.At(path) r := fsrepo.At(path)
if err := r.Open(); err != nil { if err := r.Open(); err != nil {
return err 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. // Init initializes a new FSRepo at the given path with the provided config.
func Init(path string, conf *config.Config) error { func Init(path string, conf *config.Config) error {
openerCounter.Lock() // lock must be held to ensure atomicity (prevent Removal) 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 // tilde expansion on datastore path
// TODO why is this here??
cfg.Datastore.Path, err = util.TildeExpansion(cfg.Datastore.Path) cfg.Datastore.Path, err = util.TildeExpansion(cfg.Datastore.Path)
if err != nil { if err != nil {
return nil, err return nil, err