mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Use InitWorkPathAndCfgProvider for environment-to-ini to avoid unnecessary checks (#25480)
Fix #25481 The `InitWorkPathAndCommonConfig` calls `LoadCommonSettings` which does many checks like "current user is root or not". Some commands like "environment-to-ini" shouldn't do such check, because it might be run with "root" user at the moment (eg: the docker's setup script) ps: in the future, the docker's setup script should be improved to avoid Gitea's command running with "root"
This commit is contained in:
		@@ -89,6 +89,12 @@ func (s *stringWithDefault) Set(v string) {
 | 
			
		||||
 | 
			
		||||
// InitWorkPathAndCommonConfig will set AppWorkPath, CustomPath and CustomConf, init default config provider by CustomConf and load common settings,
 | 
			
		||||
func InitWorkPathAndCommonConfig(getEnvFn func(name string) string, args ArgWorkPathAndCustomConf) {
 | 
			
		||||
	InitWorkPathAndCfgProvider(getEnvFn, args)
 | 
			
		||||
	LoadCommonSettings()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// InitWorkPathAndCfgProvider will set AppWorkPath, CustomPath and CustomConf, init default config provider by CustomConf
 | 
			
		||||
func InitWorkPathAndCfgProvider(getEnvFn func(name string) string, args ArgWorkPathAndCustomConf) {
 | 
			
		||||
	tryAbsPath := func(paths ...string) string {
 | 
			
		||||
		s := paths[len(paths)-1]
 | 
			
		||||
		for i := len(paths) - 2; i >= 0; i-- {
 | 
			
		||||
@@ -186,6 +192,4 @@ func InitWorkPathAndCommonConfig(getEnvFn func(name string) string, args ArgWork
 | 
			
		||||
	AppWorkPath = tmpWorkPath.Value
 | 
			
		||||
	CustomPath = tmpCustomPath.Value
 | 
			
		||||
	CustomConf = tmpCustomConf.Value
 | 
			
		||||
 | 
			
		||||
	LoadCommonSettings()
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user