Make some improvements to the homedir ghetto hax

This avoid breakage when inside a dev environment
This commit is contained in:
Arturo Filastò 2018-07-09 19:17:59 +02:00
parent d8cbfd1b90
commit b2faf3fd34

View File

@ -9,7 +9,6 @@ import (
"github.com/apex/log" "github.com/apex/log"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/measurement-kit/go-measurement-kit" "github.com/measurement-kit/go-measurement-kit"
homedir "github.com/mitchellh/go-homedir"
ooni "github.com/ooni/probe-cli" ooni "github.com/ooni/probe-cli"
"github.com/ooni/probe-cli/internal/cli/version" "github.com/ooni/probe-cli/internal/cli/version"
"github.com/ooni/probe-cli/internal/database" "github.com/ooni/probe-cli/internal/database"
@ -76,11 +75,13 @@ func (c *Controller) Init(nt *mk.Nettest) error {
caBundlePath := getCaBundlePath() caBundlePath := getCaBundlePath()
msmtPath := c.msmtPath msmtPath := c.msmtPath
userHome, err := homedir.Dir() userHome, err := utils.GetOONIHome()
if err != nil { if err != nil {
log.WithError(err).Error("failed to figure out the homedir") log.WithError(err).Error("failed to figure out the homedir")
return err return err
} }
// Get the parent of it
userHome = filepath.Dir(userHome)
relPath, err := filepath.Rel(userHome, caBundlePath) relPath, err := filepath.Rel(userHome, caBundlePath)
if err != nil { if err != nil {