mirror of
https://github.com/mautrix/signal.git
synced 2026-05-14 21:26:54 -04:00
Compare commits
1 commit
main
...
kb/defensi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
490f5af343 |
1 changed files with 6 additions and 5 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue