summaryrefslogtreecommitdiff
path: root/internal/media/metadata.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-09-24 15:12:25 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-09-24 15:12:25 +0200
commit3db2d42247c5f88196ae7fb68b6bbec603bb7f26 (patch)
tree4fa7e793b230757219941f5b5a936a79b77eb000 /internal/media/metadata.go
parent[docs] Update tracing.md with up-to-date way of doing things (#4452) (diff)
downloadgotosocial-3db2d42247c5f88196ae7fb68b6bbec603bb7f26.tar.xz
[chore] ffmpeg webassembly fiddling (#4454)
This disables ffmpeg / ffprobe support on platforms where the wazero compiler is not available. The slowness introduced is hard to pindown for admins (and us!), so it's easier to just return an error message linking to docs on attempted media processing. It still allows the instance to run, just erroring if anything other than a jpeg is attempted to be processed. This should hopefully make it easier for users to notice these issues. Also further locks down our wazero 'allowFiles' fs and other media code to address: https://codeberg.org/superseriousbusiness/gotosocial/issues/4408 relates to: https://codeberg.org/superseriousbusiness/gotosocial/issues/4427 also relates to issues raised in #gotosocial-help on matrix closes https://codeberg.org/superseriousbusiness/gotosocial/issues/4408 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4454 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/media/metadata.go')
-rw-r--r--internal/media/metadata.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/internal/media/metadata.go b/internal/media/metadata.go
index 44b1a87b6..c1fa58645 100644
--- a/internal/media/metadata.go
+++ b/internal/media/metadata.go
@@ -74,20 +74,28 @@ func clearMetadata(ctx context.Context, filepath string) error {
// terminateExif cleans exif data from file at input path, into file
// at output path, using given file extension to determine cleaning type.
-func terminateExif(outpath, inpath string, ext string) error {
+func terminateExif(outpath, inpath string, ext string) (err error) {
+ var inFile *os.File
+ var outFile *os.File
+
+ // Ensure handles
+ // closed on return.
+ defer func() {
+ outFile.Close()
+ inFile.Close()
+ }()
+
// Open input file at given path.
- inFile, err := os.Open(inpath)
+ inFile, err = openRead(inpath)
if err != nil {
return gtserror.Newf("error opening input file %s: %w", inpath, err)
}
- defer inFile.Close()
- // Open output file at given path.
- outFile, err := os.Create(outpath)
+ // Create output file at given path.
+ outFile, err = openWrite(outpath)
if err != nil {
return gtserror.Newf("error opening output file %s: %w", outpath, err)
}
- defer outFile.Close()
// Terminate EXIF data from 'inFile' -> 'outFile'.
err = terminator.TerminateInto(outFile, inFile, ext)