提交 bb49b019 作者: Brian Tiger Chow

use best known path method

上级 d5e4c6a0
......@@ -30,9 +30,15 @@ func main() {
// 1. --repo flag
// 2. IPFS_PATH environment variable
// 3. default repo path
ipfsPath := config.DefaultPathRoot
var ipfsPath string
if *repoPath != "" {
ipfsPath = *repoPath
} else {
var err error
ipfsPath, err = fsrepo.BestKnownPath()
if err != nil {
log.Fatal(err)
}
}
if err := run(ipfsPath, *watchPath); err != nil {
......@@ -43,7 +49,7 @@ func main() {
func run(ipfsPath, watchPath string) error {
proc := process.WithParent(process.Background())
log.Printf("running IPFSWatch on %s using repo at %s...", watchPath, ipfsPath)
log.Printf("running IPFSWatch on '%s' using repo at '%s'...", watchPath, ipfsPath)
ipfsPath, err := homedir.Expand(ipfsPath)
if err != nil {
......
package fsrepo
import (
"os"
homedir "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"
"github.com/jbenet/go-ipfs/repo/config"
)
// BestKnownPath returns the best known fsrepo path. If the ENV override is
// present, this function returns that value. Otherwise, it returns the default
// repo path.
func BestKnownPath() (string, error) {
ipfsPath := config.DefaultPathRoot
if os.Getenv(config.EnvDir) != "" {
ipfsPath = os.Getenv(config.EnvDir)
}
ipfsPath, err := homedir.Expand(ipfsPath)
if err != nil {
return "", err
}
return ipfsPath, nil
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论