This commit is contained in:
Lunny Xiao 2025-03-11 21:24:53 -07:00
parent fc448b5125
commit 1ad7ee8076
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 4 additions and 3 deletions

View File

@ -17,7 +17,7 @@ import (
)
func testRun(m *testing.M) error {
gitHomePath, err := os.MkdirTemp(os.TempDir(), "git-home")
gitHomePath, err := os.MkdirTemp(setting.TempDir(), "git-home")
if err != nil {
return fmt.Errorf("unable to create temp dir: %w", err)
}

View File

@ -23,12 +23,13 @@ var (
// AppName is the Application name, used in the page title. ini: "APP_NAME"
AppName string
tempDir string
createTempOnce sync.Once
)
// TempDir returns the OS temp directory
func TempDir() string {
tempDir := 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)
@ -38,5 +39,5 @@ func TempDir() string {
}
func CleanUpTempDirs() {
_ = os.RemoveAll(TempDir())
//_ = os.RemoveAll(TempDir())
}