mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 05:42:26 -06:00
[bugfix] Close ReadClosers properly in the media package (#434)
* defer lock reader * close readers when finished with them * close the reader in the teereader when finished
This commit is contained in:
parent
55ad6dee71
commit
73e9cca701
4 changed files with 52 additions and 18 deletions
|
|
@ -20,6 +20,7 @@ package media
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -61,3 +62,16 @@ func parseFocus(focus string) (focusx, focusy float32, err error) {
|
|||
focusy = float32(fy)
|
||||
return
|
||||
}
|
||||
|
||||
type teeReadCloser struct {
|
||||
teeReader io.Reader
|
||||
close func() error
|
||||
}
|
||||
|
||||
func (t teeReadCloser) Read(p []byte) (n int, err error) {
|
||||
return t.teeReader.Read(p)
|
||||
}
|
||||
|
||||
func (t teeReadCloser) Close() error {
|
||||
return t.close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue