master
go 23 lines 539 Bytes
Raw
1 package fsrepo
2
3 import (
4 "os"
5
6 config "github.com/ipfs/kubo/config"
7 "github.com/ipfs/kubo/misc/fsutil"
8 )
9
10 // BestKnownPath returns the best known fsrepo path. If the ENV override is
11 // present, this function returns that value. Otherwise, it returns the default
12 // repo path.
13 func BestKnownPath() (string, error) {
14 ipfsPath := config.DefaultPathRoot
15 if os.Getenv(config.EnvDir) != "" {
16 ipfsPath = os.Getenv(config.EnvDir)
17 }
18 ipfsPath, err := fsutil.ExpandHome(ipfsPath)
19 if err != nil {
20 return "", err
21 }
22 return ipfsPath, nil
23 }