mirror of
https://github.com/mautrix/signal.git
synced 2026-05-15 13:46:55 -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 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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue