summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-03-18 04:25:55 -0400
committerUnknwon <u@gogs.io>2015-03-18 04:25:55 -0400
commit49aeb87e44b315b0a2de6ce82600311bd24be9f7 (patch)
tree1e6dc764681d52f9a693183610667c632e02d37a
parent104d914b39be601ba46d5ad5f0ff095a0c710232 (diff)
downloadgitea-49aeb87e44b315b0a2de6ce82600311bd24be9f7.tar.gz
gitea-49aeb87e44b315b0a2de6ce82600311bd24be9f7.zip
#1028: Windows Expects UNIX Directory Separator
-rw-r--r--modules/setting/setting.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 9c1b0ad3c0..0bc8c99bdc 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -163,6 +163,13 @@ func WorkDir() (string, error) {
return path.Dir(strings.Replace(execPath, "\\", "/", -1)), err
}
+func forcePathSeparator(path string) {
+ if strings.Contains(path, "\\") {
+ fmt.Println("Do not use '\\' or '\\\\' in paths, instead, please use '/' in all places")
+ os.Exit(1)
+ }
+}
+
// NewConfigContext initializes configuration context.
// NOTE: do not print any log except error.
func NewConfigContext() {
@@ -196,6 +203,7 @@ func NewConfigContext() {
Cfg.NameMapper = ini.AllCapsUnderscore
LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(workDir, "log"))
+ forcePathSeparator(LogRootPath)
sec := Cfg.Section("server")
AppName = Cfg.Section("").Key("APP_NAME").MustString("Gogs: Go Git Service")
@@ -287,18 +295,22 @@ func NewConfigContext() {
if err != nil {
log.Fatal(4, "Fail to get home directory: %v", err)
}
+ homeDir = strings.Replace(homeDir, "\\", "/", -1)
+
sec = Cfg.Section("repository")
- RepoRootPath = sec.Key("ROOT").MustString(filepath.Join(homeDir, "gogs-repositories"))
+ RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gogs-repositories"))
+ forcePathSeparator(RepoRootPath)
if !filepath.IsAbs(RepoRootPath) {
- RepoRootPath = filepath.Join(workDir, RepoRootPath)
+ RepoRootPath = path.Join(workDir, RepoRootPath)
} else {
- RepoRootPath = filepath.Clean(RepoRootPath)
+ RepoRootPath = path.Clean(RepoRootPath)
}
ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
sec = Cfg.Section("picture")
PictureService = sec.Key("SERVICE").In("server", []string{"server"})
AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString("data/avatars")
+ forcePathSeparator(AvatarUploadPath)
if !filepath.IsAbs(AvatarUploadPath) {
AvatarUploadPath = path.Join(workDir, AvatarUploadPath)
}