router(server): fix panic on server deletion
Fixes https://github.com/pterodactyl/panel/issues/5028 Signed-off-by: Matthew Penner <me@matthewp.io>
This commit is contained in:
parent
d649bb1116
commit
99b9924a4a
|
@ -227,20 +227,19 @@ func deleteServer(c *gin.Context) {
|
||||||
//
|
//
|
||||||
// In addition, servers with large amounts of files can take some time to finish deleting,
|
// In addition, servers with large amounts of files can take some time to finish deleting,
|
||||||
// so we don't want to block the HTTP call while waiting on this.
|
// so we don't want to block the HTTP call while waiting on this.
|
||||||
go func(p string) {
|
go func(s *server.Server) {
|
||||||
_ = s.Filesystem().UnixFS().Close()
|
fs := s.Filesystem()
|
||||||
|
p := fs.Path()
|
||||||
|
_ = fs.UnixFS().Close()
|
||||||
if err := os.RemoveAll(p); err != nil {
|
if err := os.RemoveAll(p); err != nil {
|
||||||
log.WithFields(log.Fields{"path": p, "error": err}).Warn("failed to remove server files during deletion process")
|
log.WithFields(log.Fields{"path": p, "error": err}).Warn("failed to remove server files during deletion process")
|
||||||
}
|
}
|
||||||
}(s.Filesystem().Path())
|
}(s)
|
||||||
|
|
||||||
middleware.ExtractManager(c).Remove(func(server *server.Server) bool {
|
middleware.ExtractManager(c).Remove(func(server *server.Server) bool {
|
||||||
return server.ID() == s.ID()
|
return server.ID() == s.ID()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Deallocate the reference to this server.
|
|
||||||
s = nil
|
|
||||||
|
|
||||||
c.Status(http.StatusNoContent)
|
c.Status(http.StatusNoContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user