提交 6ec20b35 作者: Brian Tiger Chow

huh

上级 76202a94
...@@ -444,12 +444,7 @@ func getConfigRoot(req cmds.Request) (string, error) { ...@@ -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
......
...@@ -188,6 +188,7 @@ func tourGet(id tour.ID) (*tour.Topic, error) { ...@@ -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
......
...@@ -51,6 +51,14 @@ func At(repoPath string) *FSRepo { ...@@ -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)
......
...@@ -69,6 +69,7 @@ func load(filename string) (*config.Config, error) { ...@@ -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
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论