mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 01:52:26 +08:00
huh
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user