aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-03-01 04:06:57 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-03-01 04:06:57 +0800
commit43b5777709d9b867d1e2331d5586b914207f354f (patch)
treeeb25b32ad07823a442efb14aead51a08d7a811f2
parent7ab13e0f17e9d1b783d93bd4952cc6d7cc77ea7f (diff)
parenta39c73672efd542b53b79fdadb89afec93498cc1 (diff)
downloaddexon-43b5777709d9b867d1e2331d5586b914207f354f.tar
dexon-43b5777709d9b867d1e2331d5586b914207f354f.tar.gz
dexon-43b5777709d9b867d1e2331d5586b914207f354f.tar.bz2
dexon-43b5777709d9b867d1e2331d5586b914207f354f.tar.lz
dexon-43b5777709d9b867d1e2331d5586b914207f354f.tar.xz
dexon-43b5777709d9b867d1e2331d5586b914207f354f.tar.zst
dexon-43b5777709d9b867d1e2331d5586b914207f354f.zip
Merge pull request #398 from tgerring/assetpath
Check source directory for assets as last resort
-rw-r--r--ethutil/common.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/ethutil/common.go b/ethutil/common.go
index c4e7415dc..9b66763b8 100644
--- a/ethutil/common.go
+++ b/ethutil/common.go
@@ -15,11 +15,13 @@ import (
func DefaultAssetPath() string {
var assetPath string
+ pwd, _ := os.Getwd()
+ srcdir := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist")
+
// If the current working directory is the go-ethereum dir
// assume a debug build and use the source directory as
// asset directory.
- pwd, _ := os.Getwd()
- if pwd == path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist") {
+ if pwd == srcdir {
assetPath = path.Join(pwd, "assets")
} else {
switch runtime.GOOS {
@@ -35,6 +37,13 @@ func DefaultAssetPath() string {
assetPath = "."
}
}
+
+ // Check if the assetPath exists. If not, try the source directory
+ // This happens when binary is run from outside cmd/mist directory
+ if _, err := os.Stat(assetPath); os.IsNotExist(err) {
+ assetPath = path.Join(srcdir, "assets")
+ }
+
return assetPath
}