mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
feat(thumb): generate and return sidecar thumb
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
// Generator generates a thumbnail for a given reader.
|
||||
type Generator interface {
|
||||
Generate(file io.Reader, w io.Writer, name string, options map[string]string) error
|
||||
Generate(file io.Reader, name string, options map[string]string) (string, error)
|
||||
|
||||
// Priority of execution order, smaller value means higher priority.
|
||||
Priority() int
|
||||
@@ -51,19 +51,19 @@ func RegisterGenerator(generator Generator) {
|
||||
sort.Sort(Generators)
|
||||
}
|
||||
|
||||
func (p GeneratorList) Generate(file io.Reader, w io.Writer, name string, options map[string]string) error {
|
||||
func (p GeneratorList) Generate(file io.Reader, name string, options map[string]string) (string, error) {
|
||||
for _, generator := range p {
|
||||
if model.IsTrueVal(options[generator.EnableFlag()]) {
|
||||
err := generator.Generate(file, w, name, options)
|
||||
res, err := generator.Generate(file, name, options)
|
||||
if errors.Is(err, ErrPassThrough) {
|
||||
util.Log().Debug("Failed to generate thumbnail for %s: %s, passing through to next generator.", name, err)
|
||||
continue
|
||||
}
|
||||
|
||||
return err
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
return ErrNotAvailable
|
||||
return "", ErrNotAvailable
|
||||
}
|
||||
|
||||
func (p GeneratorList) Priority() int {
|
||||
|
||||
Reference in New Issue
Block a user