Support canceling an in-progress download

This commit is contained in:
Dane Everitt
2020-12-20 12:53:40 -08:00
parent c718da20e3
commit c8d297a056
5 changed files with 91 additions and 11 deletions

View File

@@ -6,6 +6,7 @@ import (
"emperror.dev/errors"
"github.com/apex/log"
"github.com/gin-gonic/gin"
"github.com/pterodactyl/wings/router/downloader"
"github.com/pterodactyl/wings/router/tokens"
"github.com/pterodactyl/wings/server"
"net/http"
@@ -210,6 +211,11 @@ func deleteServer(c *gin.Context) {
s.Throttler().StopTimer()
s.Websockets().CancelAll()
// Remove any pending remote file downloads for the server.
for _, dl := range downloader.ByServer(s.Id()) {
dl.Cancel()
}
// Destroy the environment; in Docker this will handle a running container and
// forcibly terminate it before removing the container, so we do not need to handle
// that here.