summaryrefslogtreecommitdiffstats
path: root/models/models.go
diff options
context:
space:
mode:
authorGuillaume Dube <guillaume.dube.girard@gmail.com>2017-11-03 04:56:20 -0400
committerLauris BH <lauris@nix.lv>2017-11-03 10:56:20 +0200
commit8798cf4e3ba30bc0bdea073bf273ac27b71b78ce (patch)
tree3dd0c3cc8c9448d1be0211a15b5c4094181fabed /models/models.go
parent95637e046f4cca1ce6adc0eb7e03548034dedeac (diff)
downloadgitea-8798cf4e3ba30bc0bdea073bf273ac27b71b78ce.tar.gz
gitea-8798cf4e3ba30bc0bdea073bf273ac27b71b78ce.zip
Set session and indexers' data files rel to AppDataPath (#2192)
* Set session and indexers' data files rel to AppDataPath The setting AppDataPath is now relative to the working directory. The session svc's PROVIDER_CONFIG now defaults to AppDataPath/data/sessions. The issue indexer's IssuePath now defaults to AppDataPath/indexers/issues.bleves. * fix bug
Diffstat (limited to 'models/models.go')
-rw-r--r--models/models.go23
1 files changed, 9 insertions, 14 deletions
diff --git a/models/models.go b/models/models.go
index 853b9799ed..836a14db5a 100644
--- a/models/models.go
+++ b/models/models.go
@@ -11,11 +11,11 @@ import (
"net/url"
"os"
"path"
+ "path/filepath"
"strings"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
- "code.gitea.io/gitea/modules/util"
// Needed for the MySQL driver
_ "github.com/go-sql-driver/mysql"
@@ -152,11 +152,15 @@ func LoadConfigs() {
DbCfg.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500)
sec = setting.Cfg.Section("indexer")
- setting.Indexer.IssuePath = absolutePath(
- sec.Key("ISSUE_INDEXER_PATH").MustString("indexers/issues.bleve"))
+ setting.Indexer.IssuePath = sec.Key("ISSUE_INDEXER_PATH").MustString(path.Join(setting.AppDataPath, "indexers/issues.bleve"))
+ if !filepath.IsAbs(setting.Indexer.IssuePath) {
+ setting.Indexer.IssuePath = path.Join(setting.AppWorkPath, setting.Indexer.IssuePath)
+ }
setting.Indexer.RepoIndexerEnabled = sec.Key("REPO_INDEXER_ENABLED").MustBool(false)
- setting.Indexer.RepoPath = absolutePath(
- sec.Key("REPO_INDEXER_PATH").MustString("indexers/repos.bleve"))
+ setting.Indexer.RepoPath = sec.Key("REPO_INDEXER_PATH").MustString(path.Join(setting.AppDataPath, "indexers/repos.bleve"))
+ if !filepath.IsAbs(setting.Indexer.RepoPath) {
+ setting.Indexer.RepoPath = path.Join(setting.AppWorkPath, setting.Indexer.RepoPath)
+ }
setting.Indexer.UpdateQueueLength = sec.Key("UPDATE_BUFFER_LEN").MustInt(20)
setting.Indexer.MaxIndexerFileSize = sec.Key("MAX_FILE_SIZE").MustInt64(512 * 1024 * 1024)
}
@@ -343,12 +347,3 @@ func DumpDatabase(filePath string, dbType string) error {
}
return x.DumpTablesToFile(tbs, filePath)
}
-
-// absolutePath make path absolute if it is relative
-func absolutePath(path string) string {
- workDir, err := setting.WorkDir()
- if err != nil {
- log.Fatal(4, "Failed to get work directory: %v", err)
- }
- return util.EnsureAbsolutePath(path, workDir)
-}