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 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 {
err = fallocate.Fallocate(into, int(resp.ContentLength)) if resp.ContentLength > 0 {
if err != nil { err = fallocate.Fallocate(into, int(resp.ContentLength))
return nil, fmt.Errorf("failed to pre-allocate file for attachment: %w", err) if err != nil {
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)
} }