mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-27 07:44:43 +02:00
Move all temporary directories under gitea and cleanup it when Gitea start
This commit is contained in:
parent
fafd7b73ba
commit
30621ae207
@ -153,6 +153,7 @@ func serveInstall(ctx *cli.Context) error {
|
|||||||
func serveInstalled(ctx *cli.Context) error {
|
func serveInstalled(ctx *cli.Context) error {
|
||||||
setting.InitCfgProvider(setting.CustomConf)
|
setting.InitCfgProvider(setting.CustomConf)
|
||||||
setting.LoadCommonSettings()
|
setting.LoadCommonSettings()
|
||||||
|
setting.CleanUpTempDirs()
|
||||||
setting.MustInstalled()
|
setting.MustInstalled()
|
||||||
|
|
||||||
showWebStartupMessage("Prepare to run web server")
|
showWebStartupMessage("Prepare to run web server")
|
||||||
|
@ -60,6 +60,7 @@ func InitSettings() {
|
|||||||
}
|
}
|
||||||
setting.InitCfgProvider(setting.CustomConf)
|
setting.InitCfgProvider(setting.CustomConf)
|
||||||
setting.LoadCommonSettings()
|
setting.LoadCommonSettings()
|
||||||
|
setting.CleanUpTempDirs()
|
||||||
|
|
||||||
if err := setting.PrepareAppDataPath(); err != nil {
|
if err := setting.PrepareAppDataPath(); err != nil {
|
||||||
log.Fatal("Can not prepare APP_DATA_PATH: %v", err)
|
log.Fatal("Can not prepare APP_DATA_PATH: %v", err)
|
||||||
|
@ -55,6 +55,7 @@ func TestVerifyTimeLimitCode(t *testing.T) {
|
|||||||
JWT_SECRET = %s
|
JWT_SECRET = %s
|
||||||
`, secret))
|
`, secret))
|
||||||
setting.LoadCommonSettings()
|
setting.LoadCommonSettings()
|
||||||
|
setting.CleanUpTempDirs()
|
||||||
}
|
}
|
||||||
|
|
||||||
initGeneralSecret("KZb_QLUd4fYVyxetjxC4eZkrBgWM2SndOOWDNtgUUko")
|
initGeneralSecret("KZb_QLUd4fYVyxetjxC4eZkrBgWM2SndOOWDNtgUUko")
|
||||||
|
@ -3,7 +3,10 @@
|
|||||||
|
|
||||||
package setting
|
package setting
|
||||||
|
|
||||||
import "os"
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
// Global settings
|
// Global settings
|
||||||
var (
|
var (
|
||||||
@ -21,5 +24,9 @@ var (
|
|||||||
|
|
||||||
// TempDir returns the OS temp directory
|
// TempDir returns the OS temp directory
|
||||||
func TempDir() string {
|
func TempDir() string {
|
||||||
return os.TempDir()
|
return filepath.Join(os.TempDir(), "gitea")
|
||||||
|
}
|
||||||
|
|
||||||
|
func CleanUpTempDirs() {
|
||||||
|
_ = os.RemoveAll(TempDir())
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ func (s *stringWithDefault) Set(v string) {
|
|||||||
func InitWorkPathAndCommonConfig(getEnvFn func(name string) string, args ArgWorkPathAndCustomConf) {
|
func InitWorkPathAndCommonConfig(getEnvFn func(name string) string, args ArgWorkPathAndCustomConf) {
|
||||||
InitWorkPathAndCfgProvider(getEnvFn, args)
|
InitWorkPathAndCfgProvider(getEnvFn, args)
|
||||||
LoadCommonSettings()
|
LoadCommonSettings()
|
||||||
|
CleanUpTempDirs()
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitWorkPathAndCfgProvider will set AppWorkPath, CustomPath and CustomConf, init default config provider by CustomConf
|
// InitWorkPathAndCfgProvider will set AppWorkPath, CustomPath and CustomConf, init default config provider by CustomConf
|
||||||
|
@ -535,6 +535,7 @@ func SubmitInstall(ctx *context.Context) {
|
|||||||
// Reload settings (and re-initialize database connection)
|
// Reload settings (and re-initialize database connection)
|
||||||
setting.InitCfgProvider(setting.CustomConf)
|
setting.InitCfgProvider(setting.CustomConf)
|
||||||
setting.LoadCommonSettings()
|
setting.LoadCommonSettings()
|
||||||
|
setting.CleanUpTempDirs()
|
||||||
setting.MustInstalled()
|
setting.MustInstalled()
|
||||||
setting.LoadDBSetting()
|
setting.LoadDBSetting()
|
||||||
if err := common.InitDBEngine(ctx); err != nil {
|
if err := common.InitDBEngine(ctx); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user