Skip to content

Commit 9afad75

Browse files
committed
Fix test
1 parent 3fe5cd7 commit 9afad75

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

modules/setting/global.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
package setting
55

6+
import (
7+
"os"
8+
"path/filepath"
9+
)
10+
611
// Global settings
712
var (
813
// RunUser is the OS user that Gitea is running as. ini:"RUN_USER"
@@ -19,3 +24,7 @@ var (
1924
// TempPath is the directory used for temporary files. ini: "TEMP_PATH"
2025
TempPath string
2126
)
27+
28+
func init() {
29+
TempPath = filepath.Join(os.TempDir(), "gitea")
30+
}

modules/setting/setting.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package setting
77
import (
88
"fmt"
99
"os"
10-
"path/filepath"
1110
"runtime"
1211
"strings"
1312
"time"
@@ -186,7 +185,10 @@ func loadRunModeFrom(rootCfg ConfigProvider) {
186185

187186
func loadTempDir(rootCfg ConfigProvider) {
188187
rootSec := rootCfg.Section("")
189-
TempPath = rootSec.Key("TEMP_PATH").MustString(filepath.Join(os.TempDir(), "gitea"))
188+
tempPath := rootSec.Key("TEMP_PATH").String()
189+
if tempPath != "" {
190+
TempPath = tempPath
191+
}
190192
if TempPath != "" {
191193
if err := os.MkdirAll(TempPath, os.ModePerm); err != nil {
192194
log.Fatal("Failed to create temp directory %s: %v", TempPath, err)

0 commit comments

Comments
 (0)