mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-21 12:55:23 +02:00
create temp root directory when startup
This commit is contained in:
parent
30621ae207
commit
cb812144b5
@ -4,8 +4,10 @@
|
|||||||
package setting
|
package setting
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Global settings
|
// Global settings
|
||||||
@ -20,11 +22,19 @@ var (
|
|||||||
|
|
||||||
// AppName is the Application name, used in the page title. ini: "APP_NAME"
|
// AppName is the Application name, used in the page title. ini: "APP_NAME"
|
||||||
AppName string
|
AppName string
|
||||||
|
|
||||||
|
createTempOnce sync.Once
|
||||||
)
|
)
|
||||||
|
|
||||||
// TempDir returns the OS temp directory
|
// TempDir returns the OS temp directory
|
||||||
func TempDir() string {
|
func TempDir() string {
|
||||||
return filepath.Join(os.TempDir(), "gitea")
|
tempDir := filepath.Join(os.TempDir(), "gitea")
|
||||||
|
createTempOnce.Do(func() {
|
||||||
|
if err := os.MkdirAll(tempDir, os.ModePerm); err != nil {
|
||||||
|
log.Fatalf("Failed to create temp directory %s: %v", tempDir, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return tempDir
|
||||||
}
|
}
|
||||||
|
|
||||||
func CleanUpTempDirs() {
|
func CleanUpTempDirs() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user