forked from gitea/gitea
parent
c7a21cbb0c
commit
92fda9c5a2
|
@ -53,12 +53,14 @@ var Indexer = struct {
|
||||||
func loadIndexerFrom(rootCfg ConfigProvider) {
|
func loadIndexerFrom(rootCfg ConfigProvider) {
|
||||||
sec := rootCfg.Section("indexer")
|
sec := rootCfg.Section("indexer")
|
||||||
Indexer.IssueType = sec.Key("ISSUE_INDEXER_TYPE").MustString("bleve")
|
Indexer.IssueType = sec.Key("ISSUE_INDEXER_TYPE").MustString("bleve")
|
||||||
|
if Indexer.IssueType == "bleve" {
|
||||||
Indexer.IssuePath = filepath.ToSlash(sec.Key("ISSUE_INDEXER_PATH").MustString(filepath.ToSlash(filepath.Join(AppDataPath, "indexers/issues.bleve"))))
|
Indexer.IssuePath = filepath.ToSlash(sec.Key("ISSUE_INDEXER_PATH").MustString(filepath.ToSlash(filepath.Join(AppDataPath, "indexers/issues.bleve"))))
|
||||||
if !filepath.IsAbs(Indexer.IssuePath) {
|
if !filepath.IsAbs(Indexer.IssuePath) {
|
||||||
Indexer.IssuePath = filepath.ToSlash(filepath.Join(AppWorkPath, Indexer.IssuePath))
|
Indexer.IssuePath = filepath.ToSlash(filepath.Join(AppWorkPath, Indexer.IssuePath))
|
||||||
}
|
}
|
||||||
|
fatalDuplicatedPath("issue_indexer", Indexer.IssuePath)
|
||||||
|
} else {
|
||||||
Indexer.IssueConnStr = sec.Key("ISSUE_INDEXER_CONN_STR").MustString(Indexer.IssueConnStr)
|
Indexer.IssueConnStr = sec.Key("ISSUE_INDEXER_CONN_STR").MustString(Indexer.IssueConnStr)
|
||||||
|
|
||||||
if Indexer.IssueType == "meilisearch" {
|
if Indexer.IssueType == "meilisearch" {
|
||||||
u, err := url.Parse(Indexer.IssueConnStr)
|
u, err := url.Parse(Indexer.IssueConnStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -69,6 +71,7 @@ func loadIndexerFrom(rootCfg ConfigProvider) {
|
||||||
u.User = nil
|
u.User = nil
|
||||||
Indexer.IssueConnStr = u.String()
|
Indexer.IssueConnStr = u.String()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Indexer.IssueIndexerName = sec.Key("ISSUE_INDEXER_NAME").MustString(Indexer.IssueIndexerName)
|
Indexer.IssueIndexerName = sec.Key("ISSUE_INDEXER_NAME").MustString(Indexer.IssueIndexerName)
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,12 @@ func init() {
|
||||||
AppWorkPath = filepath.Dir(AppPath)
|
AppWorkPath = filepath.Dir(AppPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fatalDuplicatedPath("app_work_path", AppWorkPath)
|
||||||
|
|
||||||
appWorkPathBuiltin = AppWorkPath
|
appWorkPathBuiltin = AppWorkPath
|
||||||
customPathBuiltin = CustomPath
|
customPathBuiltin = CustomPath
|
||||||
|
|
||||||
|
fatalDuplicatedPath("custom_path", CustomPath)
|
||||||
customConfBuiltin = CustomConf
|
customConfBuiltin = CustomConf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,9 @@ func loadRepositoryFrom(rootCfg ConfigProvider) {
|
||||||
} else {
|
} else {
|
||||||
RepoRootPath = filepath.Clean(RepoRootPath)
|
RepoRootPath = filepath.Clean(RepoRootPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fatalDuplicatedPath("repository.ROOT", RepoRootPath)
|
||||||
|
|
||||||
defaultDetectedCharsetsOrder := make([]string, 0, len(Repository.DetectedCharsetsOrder))
|
defaultDetectedCharsetsOrder := make([]string, 0, len(Repository.DetectedCharsetsOrder))
|
||||||
for _, charset := range Repository.DetectedCharsetsOrder {
|
for _, charset := range Repository.DetectedCharsetsOrder {
|
||||||
defaultDetectedCharsetsOrder = append(defaultDetectedCharsetsOrder, strings.ToLower(strings.TrimSpace(charset)))
|
defaultDetectedCharsetsOrder = append(defaultDetectedCharsetsOrder, strings.ToLower(strings.TrimSpace(charset)))
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -321,17 +320,19 @@ func loadServerFrom(rootCfg ConfigProvider) {
|
||||||
}
|
}
|
||||||
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(StaticRootPath)
|
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(StaticRootPath)
|
||||||
StaticCacheTime = sec.Key("STATIC_CACHE_TIME").MustDuration(6 * time.Hour)
|
StaticCacheTime = sec.Key("STATIC_CACHE_TIME").MustDuration(6 * time.Hour)
|
||||||
AppDataPath = sec.Key("APP_DATA_PATH").MustString(path.Join(AppWorkPath, "data"))
|
AppDataPath = sec.Key("APP_DATA_PATH").MustString(filepath.Join(AppWorkPath, "data"))
|
||||||
if !filepath.IsAbs(AppDataPath) {
|
if !filepath.IsAbs(AppDataPath) {
|
||||||
AppDataPath = filepath.ToSlash(filepath.Join(AppWorkPath, AppDataPath))
|
AppDataPath = filepath.ToSlash(filepath.Join(AppWorkPath, AppDataPath))
|
||||||
}
|
}
|
||||||
|
fatalDuplicatedPath("app_data_path", AppDataPath)
|
||||||
|
|
||||||
EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
|
EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
|
||||||
EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false)
|
EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false)
|
||||||
PprofDataPath = sec.Key("PPROF_DATA_PATH").MustString(path.Join(AppWorkPath, "data/tmp/pprof"))
|
PprofDataPath = sec.Key("PPROF_DATA_PATH").MustString(filepath.Join(AppWorkPath, "data/tmp/pprof"))
|
||||||
if !filepath.IsAbs(PprofDataPath) {
|
if !filepath.IsAbs(PprofDataPath) {
|
||||||
PprofDataPath = filepath.Join(AppWorkPath, PprofDataPath)
|
PprofDataPath = filepath.Join(AppWorkPath, PprofDataPath)
|
||||||
}
|
}
|
||||||
|
fatalDuplicatedPath("pprof_data_path", PprofDataPath)
|
||||||
|
|
||||||
landingPage := sec.Key("LANDING_PAGE").MustString("home")
|
landingPage := sec.Key("LANDING_PAGE").MustString("home")
|
||||||
switch landingPage {
|
switch landingPage {
|
||||||
|
|
|
@ -5,7 +5,6 @@ package setting
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -44,9 +43,10 @@ func loadSessionFrom(rootCfg ConfigProvider) {
|
||||||
sec := rootCfg.Section("session")
|
sec := rootCfg.Section("session")
|
||||||
SessionConfig.Provider = sec.Key("PROVIDER").In("memory",
|
SessionConfig.Provider = sec.Key("PROVIDER").In("memory",
|
||||||
[]string{"memory", "file", "redis", "mysql", "postgres", "couchbase", "memcache", "db"})
|
[]string{"memory", "file", "redis", "mysql", "postgres", "couchbase", "memcache", "db"})
|
||||||
SessionConfig.ProviderConfig = strings.Trim(sec.Key("PROVIDER_CONFIG").MustString(path.Join(AppDataPath, "sessions")), "\" ")
|
SessionConfig.ProviderConfig = strings.Trim(sec.Key("PROVIDER_CONFIG").MustString(filepath.Join(AppDataPath, "sessions")), "\" ")
|
||||||
if SessionConfig.Provider == "file" && !filepath.IsAbs(SessionConfig.ProviderConfig) {
|
if SessionConfig.Provider == "file" && !filepath.IsAbs(SessionConfig.ProviderConfig) {
|
||||||
SessionConfig.ProviderConfig = path.Join(AppWorkPath, SessionConfig.ProviderConfig)
|
SessionConfig.ProviderConfig = filepath.Join(AppWorkPath, SessionConfig.ProviderConfig)
|
||||||
|
fatalDuplicatedPath("session", SessionConfig.ProviderConfig)
|
||||||
}
|
}
|
||||||
SessionConfig.CookieName = sec.Key("COOKIE_NAME").MustString("i_like_gitea")
|
SessionConfig.CookieName = sec.Key("COOKIE_NAME").MustString("i_like_gitea")
|
||||||
SessionConfig.CookiePath = AppSubURL + "/" // there was a bug, old code only set CookePath=AppSubURL, no trailing slash
|
SessionConfig.CookiePath = AppSubURL + "/" // there was a bug, old code only set CookePath=AppSubURL, no trailing slash
|
||||||
|
|
|
@ -226,3 +226,12 @@ func LoadSettingsForInstall() {
|
||||||
loadServiceFrom(CfgProvider)
|
loadServiceFrom(CfgProvider)
|
||||||
loadMailerFrom(CfgProvider)
|
loadMailerFrom(CfgProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var uniquePaths = make(map[string]string)
|
||||||
|
|
||||||
|
func fatalDuplicatedPath(name, p string) {
|
||||||
|
if targetName, ok := uniquePaths[p]; ok && targetName != name {
|
||||||
|
log.Fatal("storage path %q is being used by %q and %q and all storage paths must be unique to prevent data loss.", p, targetName, name)
|
||||||
|
}
|
||||||
|
uniquePaths[p] = name
|
||||||
|
}
|
||||||
|
|
|
@ -240,6 +240,8 @@ func getStorageForLocal(targetSec, overrideSec ConfigSection, tp targetSecType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fatalDuplicatedPath("storage."+name, storage.Path)
|
||||||
|
|
||||||
return &storage, nil
|
return &storage, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue