1
0
Fork 0
mirror of https://github.com/mautrix/signal.git synced 2026-05-15 05:36:53 -04:00

Compare commits

...

1 commit

Author SHA1 Message Date
Kishan Bagaria
490f5af343 - 2026-03-19 10:52:30 -07:00

View file

@ -94,12 +94,13 @@ func DownloadAttachment(
var body []byte
var downloadedSize int64
if into == nil || resp.StatusCode > 400 {
body = make([]byte, resp.ContentLength)
_, err = io.ReadFull(resp.Body, body)
body, err = io.ReadAll(resp.Body)
} else {
err = fallocate.Fallocate(into, int(resp.ContentLength))
if err != nil {
return nil, fmt.Errorf("failed to pre-allocate file for attachment: %w", err)
if resp.ContentLength > 0 {
err = fallocate.Fallocate(into, int(resp.ContentLength))
if err != nil {
return nil, fmt.Errorf("failed to pre-allocate file for attachment: %w", err)
}
}
downloadedSize, err = io.Copy(into, resp.Body)
}