aboutsummaryrefslogtreecommitdiffstats
path: root/common/path.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-09-29 22:16:00 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-10-01 17:26:19 +0800
commit74578ab22b24af99ff774927a18153f464334706 (patch)
treea3651af389cfc9b72db5a78e41652a69afde5fd5 /common/path.go
parent9b94076717dfc65bda1470eecd6f61a0323f9bac (diff)
downloaddexon-74578ab22b24af99ff774927a18153f464334706.tar
dexon-74578ab22b24af99ff774927a18153f464334706.tar.gz
dexon-74578ab22b24af99ff774927a18153f464334706.tar.bz2
dexon-74578ab22b24af99ff774927a18153f464334706.tar.lz
dexon-74578ab22b24af99ff774927a18153f464334706.tar.xz
dexon-74578ab22b24af99ff774927a18153f464334706.tar.zst
dexon-74578ab22b24af99ff774927a18153f464334706.zip
common: fix #1818, secondary datadir paths to fall back to
Diffstat (limited to 'common/path.go')
-rw-r--r--common/path.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/common/path.go b/common/path.go
index 8b3c7d14b..1253c424c 100644
--- a/common/path.go
+++ b/common/path.go
@@ -100,14 +100,24 @@ func DefaultAssetPath() string {
}
func DefaultDataDir() string {
- usr, _ := user.Current()
- if runtime.GOOS == "darwin" {
- return filepath.Join(usr.HomeDir, "Library", "Ethereum")
- } else if runtime.GOOS == "windows" {
- return filepath.Join(usr.HomeDir, "AppData", "Roaming", "Ethereum")
+ // Try to place the data folder in the user's home dir
+ var home string
+ if usr, err := user.Current(); err == nil {
+ home = usr.HomeDir
} else {
- return filepath.Join(usr.HomeDir, ".ethereum")
+ home = os.Getenv("HOME")
}
+ if home != "" {
+ if runtime.GOOS == "darwin" {
+ return filepath.Join(home, "Library", "Ethereum")
+ } else if runtime.GOOS == "windows" {
+ return filepath.Join(home, "AppData", "Roaming", "Ethereum")
+ } else {
+ return filepath.Join(home, ".ethereum")
+ }
+ }
+ // As we cannot guess a stable location, return empty and handle later
+ return ""
}
func DefaultIpcPath() string {