quintodrome/core/artwork/reader_emptyid.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
755 B
Go
Raw Normal View History

2022-12-27 07:36:23 -09:00
package artwork
import (
"context"
"fmt"
"io"
"time"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/model"
)
type emptyIDReader struct {
artID model.ArtworkID
}
func newEmptyIDReader(_ context.Context, artID model.ArtworkID) (*emptyIDReader, error) {
a := &emptyIDReader{
artID: artID,
}
return a, nil
}
func (a *emptyIDReader) LastUpdated() time.Time {
return time.Now() // Basically make it non-cacheable
}
func (a *emptyIDReader) Key() string {
return fmt.Sprintf("0.%d.0.%d", a.LastUpdated().UnixMilli(), conf.Server.CoverJpegQuality)
}
func (a *emptyIDReader) Reader(ctx context.Context) (io.ReadCloser, string, error) {
r, source := extractImage(ctx, a.artID, fromPlaceholder())
return r, source, nil
}