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:
parent
105f0150f6
commit
43227bf24d
|
@ -128,6 +128,13 @@ func (t *Transfer) PushArchiveToTarget(url, token string) ([]byte, error) {
|
||||||
t.Log().Debug("sending archive to destination")
|
t.Log().Debug("sending archive to destination")
|
||||||
client := http.Client{Timeout: 0}
|
client := http.Client{Timeout: 0}
|
||||||
res, err := client.Do(req)
|
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")
|
t.Log().Debug("waiting for stream to complete")
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user