fix(album): keep cover uploads out of Recently Added ordering

Cover upload/delete bumped album.updated_at to bust the artwork cache, but
recentlyAddedSort() and Subsonic albumCreatedAt() sort on updated_at when
RecentlyAddedByModTime is enabled, so a cover edit reordered Recently Added
and shifted the reported creation date.

Add a dedicated cover_art_updated_at column that UpdateImage bumps instead of
updated_at; the album artwork id, reader cache key, and UI cover URL fold it
into their cache-busting, so covers refresh everywhere while updated_at (and
Recently Added) stays untouched.

Also preserve uploaded_image across the phase-2 moved-track album-id change,
which previously copied only created_at.
This commit is contained in:
Deluan 2026-07-17 21:08:16 -04:00
commit 319662174e
12 changed files with 116 additions and 37 deletions

View file

@ -81,8 +81,14 @@ const getAvatarUrl = (username, size) =>
)
const getCoverArtUrl = (record, size, square) => {
// Bust the cache on the newest of updatedAt / coverArtUpdatedAt (album cover
// uploads bump the latter) — ISO timestamps sort chronologically.
const cacheKey = [record.updatedAt, record.coverArtUpdatedAt]
.filter(Boolean)
.sort()
.pop()
const options = {
...(record.updatedAt && { _: record.updatedAt }),
...(cacheKey && { _: cacheKey }),
...(size && { size }),
...(square && { square }),
}

View file

@ -79,6 +79,21 @@ describe('getCoverArtUrl', () => {
expect(url).toContain('square=true')
})
it('should bust the cache on coverArtUpdatedAt when it is newer', () => {
const albumRecord = {
id: 'album-123',
albumArtist: 'Test Artist',
updatedAt: '2023-01-01T00:00:00Z',
coverArtUpdatedAt: '2024-06-01T00:00:00Z',
}
const url = subsonic.getCoverArtUrl(albumRecord)
expect(url).toContain('al-album-123')
expect(url).toContain('_=2024-06-01T00%3A00%3A00Z')
expect(url).not.toContain('_=2023-01-01')
})
it('should return media file cover art URL for records with album', () => {
const songRecord = {
id: 'song-123',