server(transfer): fix dead-lock while uploading archive

Previously we waited for both the request and multipart writer
to "complete", before handing any errors.  This lead to a problem
where if the request returns before all the data has been read,
the upload would become stuck and keep the server in a transferring
state when the transfer should've been aborted.

Closes https://github.com/pterodactyl/panel/issues/4578
This commit is contained in:
Matthew Penner 2022-11-29 14:04:27 -07:00
parent 105f0150f6
commit 43227bf24d
No known key found for this signature in database

View File

@ -128,6 +128,13 @@ func (t *Transfer) PushArchiveToTarget(url, token string) ([]byte, error) {
t.Log().Debug("sending archive to destination")
client := http.Client{Timeout: 0}
res, err := client.Do(req)
if err != nil {
t.Log().Debug("error while sending archive to destination")
return nil, err
}
if res.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status code from destination: %d", res.StatusCode)
}
t.Log().Debug("waiting for stream to complete")
select {
case <-ctx.Done():