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
783 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"
)
2022-12-27 13:05:40 -09:00
type placeholderReader struct {
2022-12-27 07:36:23 -09:00
artID model.ArtworkID
}
2022-12-27 13:05:40 -09:00
func newPlaceholderReader(_ context.Context, artID model.ArtworkID) (*placeholderReader, error) {
a := &placeholderReader{
2022-12-27 07:36:23 -09:00
artID: artID,
}
return a, nil
}
2022-12-27 13:05:40 -09:00
func (a *placeholderReader) LastUpdated() time.Time {
2022-12-27 07:36:23 -09:00
return time.Now() // Basically make it non-cacheable
}
2022-12-27 13:05:40 -09:00
func (a *placeholderReader) Key() string {
2022-12-27 07:36:23 -09:00
return fmt.Sprintf("0.%d.0.%d", a.LastUpdated().UnixMilli(), conf.Server.CoverJpegQuality)
}
2022-12-27 13:05:40 -09:00
func (a *placeholderReader) Reader(ctx context.Context) (io.ReadCloser, string, error) {
2022-12-27 07:36:23 -09:00
r, source := extractImage(ctx, a.artID, fromPlaceholder())
return r, source, nil
}