diff --git a/modules/setting/indexer.go b/modules/setting/indexer.go index 15f61502427db..16f3d80168cbc 100644 --- a/modules/setting/indexer.go +++ b/modules/setting/indexer.go @@ -53,24 +53,21 @@ var Indexer = struct { func loadIndexerFrom(rootCfg ConfigProvider) { sec := rootCfg.Section("indexer") 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")))) - if !filepath.IsAbs(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) - if Indexer.IssueType == "meilisearch" { - u, err := url.Parse(Indexer.IssueConnStr) - if err != nil { - log.Warn("Failed to parse ISSUE_INDEXER_CONN_STR: %v", err) - u = &url.URL{} - } - Indexer.IssueConnAuth, _ = u.User.Password() - u.User = nil - Indexer.IssueConnStr = u.String() + Indexer.IssuePath = filepath.ToSlash(sec.Key("ISSUE_INDEXER_PATH").MustString(filepath.ToSlash(filepath.Join(AppDataPath, "indexers/issues.bleve")))) + if !filepath.IsAbs(Indexer.IssuePath) { + Indexer.IssuePath = filepath.ToSlash(filepath.Join(AppWorkPath, Indexer.IssuePath)) + } + Indexer.IssueConnStr = sec.Key("ISSUE_INDEXER_CONN_STR").MustString(Indexer.IssueConnStr) + + if Indexer.IssueType == "meilisearch" { + u, err := url.Parse(Indexer.IssueConnStr) + if err != nil { + log.Warn("Failed to parse ISSUE_INDEXER_CONN_STR: %v", err) + u = &url.URL{} } + Indexer.IssueConnAuth, _ = u.User.Password() + u.User = nil + Indexer.IssueConnStr = u.String() } Indexer.IssueIndexerName = sec.Key("ISSUE_INDEXER_NAME").MustString(Indexer.IssueIndexerName) diff --git a/modules/setting/path.go b/modules/setting/path.go index b2cca0acbffd2..0fdc305aa160c 100644 --- a/modules/setting/path.go +++ b/modules/setting/path.go @@ -66,12 +66,8 @@ func init() { AppWorkPath = filepath.Dir(AppPath) } - fatalDuplicatedPath("app_work_path", AppWorkPath) - appWorkPathBuiltin = AppWorkPath customPathBuiltin = CustomPath - - fatalDuplicatedPath("custom_path", CustomPath) customConfBuiltin = CustomConf } diff --git a/modules/setting/repository.go b/modules/setting/repository.go index 7990021aaa2b5..a6f0ed8833589 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -285,9 +285,6 @@ func loadRepositoryFrom(rootCfg ConfigProvider) { } else { RepoRootPath = filepath.Clean(RepoRootPath) } - - fatalDuplicatedPath("repository.ROOT", RepoRootPath) - defaultDetectedCharsetsOrder := make([]string, 0, len(Repository.DetectedCharsetsOrder)) for _, charset := range Repository.DetectedCharsetsOrder { defaultDetectedCharsetsOrder = append(defaultDetectedCharsetsOrder, strings.ToLower(strings.TrimSpace(charset))) diff --git a/modules/setting/server.go b/modules/setting/server.go index 0dea4e1ac75b8..899349515f9b5 100644 --- a/modules/setting/server.go +++ b/modules/setting/server.go @@ -324,7 +324,6 @@ func loadServerFrom(rootCfg ConfigProvider) { if !filepath.IsAbs(AppDataPath) { AppDataPath = filepath.ToSlash(filepath.Join(AppWorkPath, AppDataPath)) } - fatalDuplicatedPath("app_data_path", AppDataPath) EnableGzip = sec.Key("ENABLE_GZIP").MustBool() EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false) @@ -332,7 +331,6 @@ func loadServerFrom(rootCfg ConfigProvider) { if !filepath.IsAbs(PprofDataPath) { PprofDataPath = filepath.Join(AppWorkPath, PprofDataPath) } - fatalDuplicatedPath("pprof_data_path", PprofDataPath) landingPage := sec.Key("LANDING_PAGE").MustString("home") switch landingPage { diff --git a/modules/setting/session.go b/modules/setting/session.go index 70497e5eaa8b7..e9637fdfc59f2 100644 --- a/modules/setting/session.go +++ b/modules/setting/session.go @@ -5,6 +5,7 @@ package setting import ( "net/http" + "path" "path/filepath" "strings" @@ -43,10 +44,9 @@ func loadSessionFrom(rootCfg ConfigProvider) { sec := rootCfg.Section("session") SessionConfig.Provider = sec.Key("PROVIDER").In("memory", []string{"memory", "file", "redis", "mysql", "postgres", "couchbase", "memcache", "db"}) - SessionConfig.ProviderConfig = strings.Trim(sec.Key("PROVIDER_CONFIG").MustString(filepath.Join(AppDataPath, "sessions")), "\" ") + SessionConfig.ProviderConfig = strings.Trim(sec.Key("PROVIDER_CONFIG").MustString(path.Join(AppDataPath, "sessions")), "\" ") if SessionConfig.Provider == "file" && !filepath.IsAbs(SessionConfig.ProviderConfig) { - SessionConfig.ProviderConfig = filepath.Join(AppWorkPath, SessionConfig.ProviderConfig) - fatalDuplicatedPath("session", SessionConfig.ProviderConfig) + SessionConfig.ProviderConfig = path.Join(AppWorkPath, SessionConfig.ProviderConfig) } SessionConfig.CookieName = sec.Key("COOKIE_NAME").MustString("i_like_gitea") SessionConfig.CookiePath = AppSubURL diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 13821da44d676..83b924699825e 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -229,12 +229,3 @@ func LoadSettingsForInstall() { loadServiceFrom(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 -} diff --git a/modules/setting/storage.go b/modules/setting/storage.go index 23b08df1013b8..f937c7cff3990 100644 --- a/modules/setting/storage.go +++ b/modules/setting/storage.go @@ -240,8 +240,6 @@ func getStorageForLocal(targetSec, overrideSec ConfigSection, tp targetSecType, } } - fatalDuplicatedPath("storage."+name, storage.Path) - return &storage, nil }