diff options
Diffstat (limited to 'internal/media/util.go')
-rw-r--r-- | internal/media/util.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/internal/media/util.go b/internal/media/util.go index fa5c2bfd6..fa170965f 100644 --- a/internal/media/util.go +++ b/internal/media/util.go @@ -120,15 +120,17 @@ func getMimeType(ext string) string { // chance that Linux's sendfile syscall can be utilised for optimal // draining of data source to temporary file storage. func drainToTmp(rc io.ReadCloser) (string, error) { - tmp, err := os.CreateTemp(os.TempDir(), "gotosocial-*") + defer rc.Close() + + // Open new temporary file. + tmp, err := os.CreateTemp( + os.TempDir(), + "gotosocial-*", + ) if err != nil { return "", err } - - // Close readers - // on func return. defer tmp.Close() - defer rc.Close() // Extract file path. path := tmp.Name() |