mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
Return error when scanning avif in zip (#6356)
This commit is contained in:
parent
69fd073d5d
commit
e213fde0cc
1 changed files with 4 additions and 2 deletions
|
|
@ -2,6 +2,7 @@ package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -19,6 +20,8 @@ import (
|
||||||
_ "golang.org/x/image/webp"
|
_ "golang.org/x/image/webp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ErrUnsupportedAVIFInZip = errors.New("AVIF images in zip files is unsupported")
|
||||||
|
|
||||||
// Decorator adds image specific fields to a File.
|
// Decorator adds image specific fields to a File.
|
||||||
type Decorator struct {
|
type Decorator struct {
|
||||||
FFProbe *ffmpeg.FFProbe
|
FFProbe *ffmpeg.FFProbe
|
||||||
|
|
@ -32,8 +35,7 @@ func (d *Decorator) Decorate(ctx context.Context, fs models.FS, f models.File) (
|
||||||
if _, isOs := fs.(*file.OsFS); !isOs {
|
if _, isOs := fs.(*file.OsFS); !isOs {
|
||||||
// AVIF images inside zip files are not supported
|
// AVIF images inside zip files are not supported
|
||||||
if strings.ToLower(filepath.Ext(base.Path)) == ".avif" {
|
if strings.ToLower(filepath.Ext(base.Path)) == ".avif" {
|
||||||
logger.Warnf("Skipping AVIF image in zip file: %s", base.Path)
|
return nil, fmt.Errorf("%w: %s", ErrUnsupportedAVIFInZip, base.Path)
|
||||||
return f, nil
|
|
||||||
}
|
}
|
||||||
logger.Debugf("assuming ImageFile for non-OsFS file %q", base.Path)
|
logger.Debugf("assuming ImageFile for non-OsFS file %q", base.Path)
|
||||||
return decorateFallback(fs, f)
|
return decorateFallback(fs, f)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue