Don't allow a reinstall while server is processing a power action; closes pterodactyl/panel#2409
This commit is contained in:
		
							parent
							
								
									ae5005baa3
								
							
						
					
					
						commit
						fb24ad58b4
					
				| 
						 | 
					@ -169,9 +169,16 @@ func postServerInstall(c *gin.Context) {
 | 
				
			||||||
func postServerReinstall(c *gin.Context) {
 | 
					func postServerReinstall(c *gin.Context) {
 | 
				
			||||||
	s := GetServer(c.Param("server"))
 | 
						s := GetServer(c.Param("server"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	go func(serv *server.Server) {
 | 
						if s.ExecutingPowerAction() {
 | 
				
			||||||
		if err := serv.Reinstall(); err != nil {
 | 
							c.AbortWithStatusJSON(http.StatusConflict, gin.H{
 | 
				
			||||||
			serv.Log().WithField("error", err).Error("failed to complete server re-install process")
 | 
								"error": "Cannot execute server reinstall event while another power action is running.",
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						go func(s *server.Server) {
 | 
				
			||||||
 | 
							if err := s.Reinstall(); err != nil {
 | 
				
			||||||
 | 
								s.Log().WithField("error", err).Error("failed to complete server re-install process")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}(s)
 | 
						}(s)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -168,7 +168,7 @@ func (s *Server) onBeforeStart() error {
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		s.PublishConsoleOutputFromDaemon("Checking server disk space usage, this could take a few seconds...")
 | 
							s.PublishConsoleOutputFromDaemon("Checking server disk space usage, this could take a few seconds...")
 | 
				
			||||||
		if !s.Filesystem.HasSpaceAvailable(false) {
 | 
							if !s.Filesystem.HasSpaceAvailable(false) {
 | 
				
			||||||
			return errors.New("cannot start server, not enough disk space available")
 | 
								return ErrNotEnoughDiskSpace
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user