Skip to content

Commit 1b22e23

Browse files
tulircrazycodezombie
authored andcommitted
download: seek to start of file before retrying http request
1 parent 190adb9 commit 1b22e23

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

download-to-file.go

+4
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ func (cli *Client) downloadPossiblyEncryptedMediaWithRetriesToFile(url string, c
132132
retryDuration = retryafter.Parse(httpErr.Response.Header.Get("Retry-After"), retryDuration)
133133
}
134134
cli.Log.Warnf("Failed to download media due to network error: %v, retrying in %s...", err, retryDuration)
135+
_, err = file.Seek(0, io.SeekStart)
136+
if err != nil {
137+
return nil, fmt.Errorf("failed to seek to start of file to retry download: %w", err)
138+
}
135139
time.Sleep(retryDuration)
136140
}
137141
return

0 commit comments

Comments
 (0)