mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Resize if requested
This commit is contained in:
parent
7b87386089
commit
213ceeca78
6 changed files with 163 additions and 36 deletions
|
@ -18,15 +18,15 @@ var (
|
|||
type ArtworkID struct {
|
||||
Kind Kind
|
||||
ID string
|
||||
LastAccess time.Time
|
||||
LastUpdate time.Time
|
||||
}
|
||||
|
||||
func (id ArtworkID) String() string {
|
||||
s := fmt.Sprintf("%s-%s", id.Kind.prefix, id.ID)
|
||||
if id.LastAccess.Unix() < 0 {
|
||||
if id.LastUpdate.Unix() < 0 {
|
||||
return s + "-0"
|
||||
}
|
||||
return fmt.Sprintf("%s-%x", s, id.LastAccess.Unix())
|
||||
return fmt.Sprintf("%s-%x", s, id.LastUpdate.Unix())
|
||||
}
|
||||
|
||||
func ParseArtworkID(id string) (ArtworkID, error) {
|
||||
|
@ -44,7 +44,7 @@ func ParseArtworkID(id string) (ArtworkID, error) {
|
|||
return ArtworkID{
|
||||
Kind: Kind{parts[0]},
|
||||
ID: parts[1],
|
||||
LastAccess: time.Unix(lastUpdate, 0),
|
||||
LastUpdate: time.Unix(lastUpdate, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ func artworkIDFromAlbum(al Album) ArtworkID {
|
|||
return ArtworkID{
|
||||
Kind: KindAlbumArtwork,
|
||||
ID: al.ID,
|
||||
LastAccess: al.UpdatedAt,
|
||||
LastUpdate: al.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,6 @@ func artworkIDFromMediaFile(mf MediaFile) ArtworkID {
|
|||
return ArtworkID{
|
||||
Kind: KindMediaFileArtwork,
|
||||
ID: mf.ID,
|
||||
LastAccess: mf.UpdatedAt,
|
||||
LastUpdate: mf.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,14 +14,14 @@ var _ = Describe("ParseArtworkID()", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(id.Kind).To(Equal(model.KindAlbumArtwork))
|
||||
Expect(id.ID).To(Equal("1234"))
|
||||
Expect(id.LastAccess).To(Equal(time.Unix(255, 0)))
|
||||
Expect(id.LastUpdate).To(Equal(time.Unix(255, 0)))
|
||||
})
|
||||
It("parses media file artwork ids", func() {
|
||||
id, err := model.ParseArtworkID("mf-a6f8d2b1-ffff")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(id.Kind).To(Equal(model.KindMediaFileArtwork))
|
||||
Expect(id.ID).To(Equal("a6f8d2b1"))
|
||||
Expect(id.LastAccess).To(Equal(time.Unix(65535, 0)))
|
||||
Expect(id.LastUpdate).To(Equal(time.Unix(65535, 0)))
|
||||
})
|
||||
It("fails to parse malformed ids", func() {
|
||||
_, err := model.ParseArtworkID("a6f8d2b1")
|
||||
|
|
|
@ -46,7 +46,7 @@ func (pls Playlist) MediaFiles() MediaFiles {
|
|||
func (pls *Playlist) RemoveTracks(idxToRemove []int) {
|
||||
var newTracks PlaylistTracks
|
||||
for i, t := range pls.Tracks {
|
||||
if slices.Index(idxToRemove, i) >= 0 {
|
||||
if slices.Contains(idxToRemove, i) {
|
||||
continue
|
||||
}
|
||||
newTracks = append(newTracks, t)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue