mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-08 17:05:45 +02:00
create temp root directory when startup
This commit is contained in:
parent
30621ae207
commit
cb812144b5
@ -4,8 +4,10 @@
|
||||
package setting
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Global settings
|
||||
@ -20,11 +22,19 @@ var (
|
||||
|
||||
// AppName is the Application name, used in the page title. ini: "APP_NAME"
|
||||
AppName string
|
||||
|
||||
createTempOnce sync.Once
|
||||
)
|
||||
|
||||
// TempDir returns the OS temp directory
|
||||
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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user