Skip to content

Commit 4990e0a

Browse files
committed
Use filepath.ToSlash and Join in indexer defaults and queues
As revealed by go-gitea#15964 there is inconsistent use of filepath Join and path Join for these directories. The best thing to do is to use filepath.Join but then ToSlash them for consistency. Signed-off-by: Andrew Thornton <[email protected]>
1 parent 5285a3e commit 4990e0a

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

modules/setting/indexer.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package setting
66

77
import (
8-
"path"
98
"path/filepath"
109
"strings"
1110
"time"
@@ -68,23 +67,23 @@ var (
6867
func newIndexerService() {
6968
sec := Cfg.Section("indexer")
7069
Indexer.IssueType = sec.Key("ISSUE_INDEXER_TYPE").MustString("bleve")
71-
Indexer.IssuePath = sec.Key("ISSUE_INDEXER_PATH").MustString(path.Join(AppDataPath, "indexers/issues.bleve"))
70+
Indexer.IssuePath = filepath.ToSlash(sec.Key("ISSUE_INDEXER_PATH").MustString(filepath.ToSlash(filepath.Join(AppDataPath, "indexers/issues.bleve"))))
7271
if !filepath.IsAbs(Indexer.IssuePath) {
73-
Indexer.IssuePath = path.Join(AppWorkPath, Indexer.IssuePath)
72+
Indexer.IssuePath = filepath.ToSlash(filepath.Join(AppWorkPath, Indexer.IssuePath))
7473
}
7574
Indexer.IssueConnStr = sec.Key("ISSUE_INDEXER_CONN_STR").MustString(Indexer.IssueConnStr)
7675
Indexer.IssueIndexerName = sec.Key("ISSUE_INDEXER_NAME").MustString(Indexer.IssueIndexerName)
7776

7877
Indexer.IssueQueueType = sec.Key("ISSUE_INDEXER_QUEUE_TYPE").MustString(LevelQueueType)
79-
Indexer.IssueQueueDir = sec.Key("ISSUE_INDEXER_QUEUE_DIR").MustString(path.Join(AppDataPath, "queues/common"))
78+
Indexer.IssueQueueDir = filepath.ToSlash(sec.Key("ISSUE_INDEXER_QUEUE_DIR").MustString(filepath.ToSlash(filepath.Join(AppDataPath, "queues/common"))))
8079
Indexer.IssueQueueConnStr = sec.Key("ISSUE_INDEXER_QUEUE_CONN_STR").MustString("")
8180
Indexer.IssueQueueBatchNumber = sec.Key("ISSUE_INDEXER_QUEUE_BATCH_NUMBER").MustInt(20)
8281

8382
Indexer.RepoIndexerEnabled = sec.Key("REPO_INDEXER_ENABLED").MustBool(false)
8483
Indexer.RepoType = sec.Key("REPO_INDEXER_TYPE").MustString("bleve")
85-
Indexer.RepoPath = sec.Key("REPO_INDEXER_PATH").MustString(path.Join(AppDataPath, "indexers/repos.bleve"))
84+
Indexer.RepoPath = filepath.ToSlash(sec.Key("REPO_INDEXER_PATH").MustString(filepath.ToSlash(filepath.Join(AppDataPath, "indexers/repos.bleve"))))
8685
if !filepath.IsAbs(Indexer.RepoPath) {
87-
Indexer.RepoPath = path.Join(AppWorkPath, Indexer.RepoPath)
86+
Indexer.RepoPath = filepath.ToSlash(filepath.Join(AppWorkPath, Indexer.RepoPath))
8887
}
8988
Indexer.RepoConnStr = sec.Key("REPO_INDEXER_CONN_STR").MustString("")
9089
Indexer.RepoIndexerName = sec.Key("REPO_INDEXER_NAME").MustString("gitea_codes")

modules/setting/queue.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func GetQueueSettings(name string) QueueSettings {
4848
q.Name = name
4949

5050
// DataDir is not directly inheritable
51-
q.DataDir = filepath.Join(Queue.DataDir, "common")
51+
q.DataDir = filepath.ToSlash(filepath.Join(Queue.DataDir, "common"))
5252
// QueueName is not directly inheritable either
5353
q.QueueName = name + Queue.QueueName
5454
for _, key := range sec.Keys() {
@@ -91,9 +91,9 @@ func GetQueueSettings(name string) QueueSettings {
9191
// This is exported for tests to be able to use the queue
9292
func NewQueueService() {
9393
sec := Cfg.Section("queue")
94-
Queue.DataDir = sec.Key("DATADIR").MustString("queues/")
94+
Queue.DataDir = filepath.ToSlash(sec.Key("DATADIR").MustString("queues/"))
9595
if !filepath.IsAbs(Queue.DataDir) {
96-
Queue.DataDir = filepath.Join(AppDataPath, Queue.DataDir)
96+
Queue.DataDir = filepath.ToSlash(filepath.Join(AppDataPath, Queue.DataDir))
9797
}
9898
Queue.QueueLength = sec.Key("LENGTH").MustInt(20)
9999
Queue.BatchLength = sec.Key("BATCH_LENGTH").MustInt(20)

0 commit comments

Comments
 (0)