Fix oversight

This commit is contained in:
Xpl0itU 2024-04-02 16:29:48 +02:00 committed by GitHub
parent bea31a1ab7
commit 02be2175be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -100,30 +100,31 @@ func downloadFile(ctx context.Context, progressReporter ProgressReporter, client
default:
n, err := resp.Body.Read(buffer)
if err != nil && err != io.EOF {
resp.Body.Close()
file.Close()
if doRetries && attempt < maxRetries {
time.Sleep(retryDelay)
isError = true
break Loop
}
resp.Body.Close()
file.Close()
return fmt.Errorf("download error after %d attempts: %+v", attempt, err)
}
if n == 0 {
resp.Body.Close()
file.Close()
break Loop
}
_, err = file.Write(buffer[:n])
if err != nil {
resp.Body.Close()
file.Close()
if doRetries && attempt < maxRetries {
time.Sleep(retryDelay)
isError = true
break Loop
}
resp.Body.Close()
file.Close()
return fmt.Errorf("write error after %d attempts: %+v", attempt, err)
}