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,
|
||||
// so we don't want to block the HTTP call while waiting on this.
|
||||
go func(p string) {
|
||||
_ = s.Filesystem().UnixFS().Close()
|
||||
go func(s *server.Server) {
|
||||
fs := s.Filesystem()
|
||||
p := fs.Path()
|
||||
_ = fs.UnixFS().Close()
|
||||
if err := os.RemoveAll(p); err != nil {
|
||||
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 {
|
||||
return server.ID() == s.ID()
|
||||
})
|
||||
|
||||
// Deallocate the reference to this server.
|
||||
s = nil
|
||||
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user