summaryrefslogtreecommitdiff
path: root/internal/processing/media/util.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-03-21 13:41:44 +0100
committerLibravatar GitHub <noreply@github.com>2022-03-21 13:41:44 +0100
commit73e9cca7019c15a92cb4cd320034652590513198 (patch)
tree188f4e26b49536d40c455587b171053abf05e4d3 /internal/processing/media/util.go
parent[feature] Admin account actions (#432) (diff)
downloadgotosocial-73e9cca7019c15a92cb4cd320034652590513198.tar.xz
[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
Diffstat (limited to 'internal/processing/media/util.go')
-rw-r--r--internal/processing/media/util.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/processing/media/util.go b/internal/processing/media/util.go
index 37dc87979..9739e70b7 100644
--- a/internal/processing/media/util.go
+++ b/internal/processing/media/util.go
@@ -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()
+}