[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:
tobi 2022-03-21 13:41:44 +01:00 committed by GitHub
commit 73e9cca701
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 18 deletions

View file

@ -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()
}