mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 01:32:25 -05:00
[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>
This commit is contained in:
parent
121677754c
commit
3db2d42247
7 changed files with 111 additions and 97 deletions
|
|
@ -24,7 +24,6 @@ import (
|
|||
"image/jpeg"
|
||||
"image/png"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"code.superseriousbusiness.org/gotosocial/internal/gtserror"
|
||||
|
|
@ -89,8 +88,8 @@ func generateThumb(
|
|||
// Default type is webp.
|
||||
mimeType = "image/webp"
|
||||
|
||||
// Generate thumb output path REPLACING extension.
|
||||
if i := strings.IndexByte(filepath, '.'); i != -1 {
|
||||
// Generate thumb output path REPLACING file extension.
|
||||
if i := strings.LastIndexByte(filepath, '.'); i != -1 {
|
||||
outpath = filepath[:i] + "_thumb.webp"
|
||||
ext = filepath[i+1:] // old extension
|
||||
} else {
|
||||
|
|
@ -231,7 +230,7 @@ func generateNativeThumb(
|
|||
error,
|
||||
) {
|
||||
// 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)
|
||||
}
|
||||
|
|
@ -272,7 +271,7 @@ func generateNativeThumb(
|
|||
)
|
||||
|
||||
// Open output file at given path.
|
||||
outfile, err := os.Create(outpath)
|
||||
outfile, err := openWrite(outpath)
|
||||
if err != nil {
|
||||
return "", gtserror.Newf("error opening output file %s: %w", outpath, err)
|
||||
}
|
||||
|
|
@ -313,8 +312,9 @@ func generateNativeThumb(
|
|||
|
||||
// generateWebpBlurhash generates a blurhash for Webp at filepath.
|
||||
func generateWebpBlurhash(filepath string) (string, error) {
|
||||
|
||||
// Open the file at given path.
|
||||
file, err := os.Open(filepath)
|
||||
file, err := openRead(filepath)
|
||||
if err != nil {
|
||||
return "", gtserror.Newf("error opening input file %s: %w", filepath, err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue