We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 30621ae commit cb81214Copy full SHA for cb81214
modules/setting/global.go
@@ -4,8 +4,10 @@
4
package setting
5
6
import (
7
+ "log"
8
"os"
9
"path/filepath"
10
+ "sync"
11
)
12
13
// Global settings
@@ -20,11 +22,19 @@ var (
20
22
21
23
// AppName is the Application name, used in the page title. ini: "APP_NAME"
24
AppName string
25
+
26
+ createTempOnce sync.Once
27
28
29
// TempDir returns the OS temp directory
30
func TempDir() string {
- return filepath.Join(os.TempDir(), "gitea")
31
+ tempDir := filepath.Join(os.TempDir(), "gitea")
32
+ createTempOnce.Do(func() {
33
+ if err := os.MkdirAll(tempDir, os.ModePerm); err != nil {
34
+ log.Fatalf("Failed to create temp directory %s: %v", tempDir, err)
35
+ }
36
+ })
37
+ return tempDir
38
}
39
40
func CleanUpTempDirs() {
0 commit comments