From fb24ad58b45061daad8e242ed64c4aef64c09f61 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Fri, 25 Sep 2020 20:03:04 -0700 Subject: [PATCH] Don't allow a reinstall while server is processing a power action; closes pterodactyl/panel#2409 --- router/router_server.go | 13 ++++++++++--- server/power.go | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/router/router_server.go b/router/router_server.go index 231da0a..0ed370a 100644 --- a/router/router_server.go +++ b/router/router_server.go @@ -169,9 +169,16 @@ func postServerInstall(c *gin.Context) { func postServerReinstall(c *gin.Context) { s := GetServer(c.Param("server")) - go func(serv *server.Server) { - if err := serv.Reinstall(); err != nil { - serv.Log().WithField("error", err).Error("failed to complete server re-install process") + if s.ExecutingPowerAction() { + c.AbortWithStatusJSON(http.StatusConflict, gin.H{ + "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) diff --git a/server/power.go b/server/power.go index 35e8d5f..d86f872 100644 --- a/server/power.go +++ b/server/power.go @@ -168,7 +168,7 @@ func (s *Server) onBeforeStart() error { } else { s.PublishConsoleOutputFromDaemon("Checking server disk space usage, this could take a few seconds...") if !s.Filesystem.HasSpaceAvailable(false) { - return errors.New("cannot start server, not enough disk space available") + return ErrNotEnoughDiskSpace } }