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

Compare commits

...

1 commit

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

View file

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