diff options
author | Unknown <joe2010xtmf@163.com> | 2014-05-07 17:04:32 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-05-07 17:04:32 -0400 |
commit | 269281ab767730817b2e468507e7a468c30337ac (patch) | |
tree | 964cd999a52c4154279cb462031e9b23e343d111 /models/publickey.go | |
parent | 4b08d3aacf1ab3d9e883a891663523b7b536c8a5 (diff) | |
download | gitea-269281ab767730817b2e468507e7a468c30337ac.tar.gz gitea-269281ab767730817b2e468507e7a468c30337ac.zip |
Bug fix
Diffstat (limited to 'models/publickey.go')
-rw-r--r-- | models/publickey.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/models/publickey.go b/models/publickey.go index 7ef25b9ceb..556db96491 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -11,6 +11,7 @@ import ( "io" "io/ioutil" "os" + "os/exec" "path" "path/filepath" "strings" @@ -20,7 +21,6 @@ import ( "github.com/Unknwon/com" qlog "github.com/qiniu/log" - "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" ) @@ -41,6 +41,15 @@ var ( appPath string // Execution(binary) path. ) +// exePath returns the executable path. +func exePath() (string, error) { + file, err := exec.LookPath(os.Args[0]) + if err != nil { + return "", err + } + return filepath.Abs(file) +} + // homeDir returns the home directory of current user. func homeDir() string { home, err := com.HomeDir() @@ -53,7 +62,7 @@ func homeDir() string { func init() { var err error - if appPath, err = base.ExecDir(); err != nil { + if appPath, err = exePath(); err != nil { qlog.Fatalf("publickey.init(fail to get app path): %v\n", err) } |