summaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-02 11:41:28 +0800
committerUnknwon <u@gogs.io>2015-08-02 11:41:28 +0800
commit1490e862cc9883a8802c9a92da28312bd1663ac0 (patch)
tree3199b36a43adc542a6a96d55e6091ac284dea521 /modules/setting
parentcc0d963f75593cb37a84077408b0bd2abdc6e29b (diff)
downloadgitea-1490e862cc9883a8802c9a92da28312bd1663ac0.tar.gz
gitea-1490e862cc9883a8802c9a92da28312bd1663ac0.zip
custom workDir function to handle speical case in Windows
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/setting.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index f826a3a41a..9e9e564b4c 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -168,7 +168,18 @@ func ExecPath() (string, error) {
// WorkDir returns absolute path of work directory.
func WorkDir() (string, error) {
execPath, err := ExecPath()
- return path.Dir(strings.Replace(execPath, "\\", "/", -1)), err
+ if err != nil {
+ return execPath, err
+ }
+
+ // Note: we don't use path.Dir here because it does not handle case
+ // which path starts with two "/" in Windows: "//psf/Home/..."
+ execPath = strings.Replace(execPath, "\\", "/", -1)
+ i := strings.LastIndex(execPath, "/")
+ if i == -1 {
+ return execPath, nil
+ }
+ return execPath[:i], nil
}
func forcePathSeparator(path string) {