Commit Graph
3950 Commits
Author SHA1 Message Date
zarzet caa4c4ef3b fix(link): rank web cover copies after every other cover
A web cover copy in a catalog's coverPath outranked real pictures: an
album's cover is its first song with a cover file, and every id tries
cover files before embedded pictures, so an album mixing a song that
embeds its picture (or a later song with a cover file) with a web-only
song served the copy for every song.

Catalog lines now carry copies in their own webCoverPath field. The
server tries them only after the cover files and embedded pictures it
tried before, the song's own copy first and then its album's; an album
falls back to its first song with a copy only when no song has a cover
file or an embeddable format, and an artist to such an album only when
no other has a cover. Ids that had any cover serve exactly what they
served before, and a catalog without the field reads as before.

A failed read of an audio file is no longer remembered as a file
without a picture, for getCoverArt and linkEmbeddedPictures alike; only
a file that was read through counts.
2026-10-30 19:41:42 +07:00
zarzet d60e13dca3 fix(link): use a web cover copy only for songs without a picture
Every default download keeps an https cover address and also embeds its
cover, so round 1 copied the web cover of every download and the
catalog's coverPath then outranked the picture in the file. The owner
approved web covers only for songs with no other cover.

The exporter now reports each song without a local cover file but with a
public https cover (path, path+mtime+size stamp, address) and names a
copy only for a song whose file is known to embed no picture. The store
asks linkEmbeddedPictures about new file versions in batches of 64 on
the Rust worker pool, keeps the answers in pictures.json, keeps the
copies a song may still want, fetches only for songs known to embed
none, and announces a held copy a newly asked file can take.

Also from the review: the host stops the store only after the server
stopped, so an export finishing meanwhile fetches nothing; web cover
fetches take https only, refuse localhost and loopback, link-local and
private literals, check every redirect by hand and end after a minute;
once the store is full it fetches and retries nothing until a prune
frees space; a failed write removes its staged file. Phone covers keep
their fetch unchanged.
2026-10-30 19:41:42 +07:00
zarzet 6c35c81a6f feat(link): tell the desktop which audio files embed a picture
The desktop should fetch a web cover only for a song whose file has no
picture of its own. linkEmbeddedPictures answers, for a list of paths,
whether each file embeds a picture getCoverArt would serve (null when it
is not a readable file). It reuses mornye_core's cover extraction and the
server's format table and remembered files without a picture, so a later
getCoverArt does not read them again. Works while the server is stopped.
2026-10-30 19:41:42 +07:00
zarzet 48f8e85881 fix(link): serve desktop web-only covers from a lasting Link folder
A desktop download saved without embedded metadata has only an https
cover. The catalog left coverPath empty for it and the server answered
getCoverArt with 404, so the phone showed a placeholder while the
desktop showed the web cover.

LinkWebCovers keeps one copy per address in <app support>/link_web_covers
(<linkCoverUrlId(url)>.<ext>), fetched with the phone covers' fetch,
image check and staged write, now shared from link_web_covers.dart.
Each export lists the copies held and names them as coverPath; songs
with a local cover file and the desktop identity index are unchanged.
Once the server has loaded a catalog, the host removes the copies no
exported song wants and fetches the missing ones in the background,
4 at a time, with a byte cap and a timeout; failures wait 1 minute,
doubling up to 6 hours. New copies schedule an export, whose
catalog.changed makes phones rescan and fetch the cover.

A catalog only names files that exist, so Rust needs no change and an
album never prefers a copy that has not arrived. The listing an export
starts with waits for a queued removal, and removals run only after
setCatalog, so no file the server names is removed.
2026-10-30 19:41:42 +07:00
zarzet 515cfaf231 fix(replaygain): recognize Opus gain tags consistently 2026-10-30 19:39:35 +07:00
zarzet 361d97fa03 fix(covers): show a collection song's network cover only where it loads
A Loved or playlist song of a network connection now stores its
network:// cover reference, and three paths handled it poorly:

- A song that resolves to a local file (a later download, or a Library
  match) played with the reference as its artwork, which blocked the
  embedded cover recovery and fetched over the connection while the
  local file played. The reference now applies only to a network
  source; a local file shows its own cover as before.
- Go to album passed the reference into album pages and recents, which
  load covers over http only, so the page showed a failed cover instead
  of the provider's. It now passes http covers only; a store path never
  loaded there either.
- The writer compared the shown cover against the default store, while
  the player chose it with its runtime's store. The player provider and
  the media controls now pass the runtime's store. It is the same
  object in production.
2026-10-30 18:55:58 +07:00
zarzet 312b1340ad fix(link): keep a song's network cover when a peer's edit comes back
Collection songs go out without their network:// cover, so a change
the peer authors for such a row comes back without one. A desktop
playlist reorder restamps every member, and saving a Loved song again
rewrites it; applying either replaced the phone's row and dropped the
reference for good. Before F2 the phone's store path made the same
round trip and came back unchanged.

apply now reads, inside its transaction, the rows that winning Loved,
wishlist and playlist song changes without a cover replace, and keeps
a network:// cover they hold. A cover the peer sends still wins, and
the reference still never leaves the device. Every collection receive
path (the phone's pull, the desktop's POST, the full exchange after a
replaced database) applies through this method.
2026-10-30 18:55:58 +07:00
zarzet 782759cc36 fix(covers): keep the network cover reference of Loved and playlist songs
A network song without a Library record (a WebDAV, SMB or Subsonic
browser song, a Link desktop song) was saved to Loved or a playlist
with the file its player item showed, a cover store file. The store
trims those files, and on iOS their container path changes with an
app update, so the entry lost its cover.

collectionTrackForMedia now keeps the item's artworkRef while the item
shows that cover or none yet: the store fetches it again after a trim,
and collection rows already show a network:// cover through the store
(pendingCover). A cover read from the song's tags (#cover, which no
server answers) or any other artwork is kept as before.
CoverStore.refetches names the references a trim cannot lose.

playableFromTrack turned a network:// cover into a file URI of that
string; it now keeps the reference as the media's coverReference, so
the player shows the stored file and the item never carries network://
as its artUri. Track.fromJson already reads the reference unchanged,
and older rows read and play exactly as before.
2026-10-30 18:55:58 +07:00
zarzet 482206b404 fix(link): sync collection songs without network cover references
A network:// cover names a connection of the device that saved it, so
it means nothing on the peer. Loved, wishlist and playlist entries now
go out without one; the author's own row keeps it. Other covers are
sent unchanged, so existing rows sync exactly as before.
2026-10-30 18:55:58 +07:00
zarzet 633849c9b0 fix(downloads): keep network cover references out of the download queue
A Loved or playlist entry of a network song will keep its cover as a
network:// reference, which only this device's cover store reads. Such
a track can reach the download queue (a tap on an entry without a
download, Download all), where the queue tiles load the cover over http,
the request payload hands it to the backend as a cover URL to fetch and
embed, and post-processing hooks receive it.

The queue now stores such a track without that cover, so the backend
falls back to the provider's cover. Other tracks are queued unchanged
(the same instance). The quality picker loads its cover with
Image.network, so it now gets only an http cover; a local path showed
the same placeholder there before.
2026-10-30 18:55:58 +07:00
zarzet 7db4842096 fix(android): close a cover descriptor on any failed check
An unexpected runtime error between the open and the image check left
the descriptor open, so a binder thread of the cover provider could leak
it. The descriptor is now closed in a finally block whenever no image
type was found.
2026-10-30 18:53:55 +07:00
zarzet a7f84b6df0 fix(android): show local covers in Android Auto's queue view
The car's queue view loads each queue item's icon URI in its own process,
so a local song's app-private file:// cover showed nothing there, while
its browse entry already shows the cover through the cover provider.

audio_service gains AudioServicePlugin.setQueueArtResolver (recorded in
MORNYE_PATCHES.md). raw2queue applies it to each QueueItem description
only; the item's MediaMetadataCompat, the metadata cache, the playing
item, the notification and the lock screen keep the original artwork.
A null answer, a resolver that throws, or no resolver keeps the
description as it was.

The app's resolver maps a file:// or plain absolute path that names a
cover directly in the provider's folders, read from the path alone with
the same per-folder name rules, to the provider URI its browse entry
gets, so the car's cache sees one URI per cover.
2026-10-30 18:53:55 +07:00
zarzet 9019e853fd fix(android): check cover names per folder and serve the opened file
The cover folders also hold files that are not covers: `.source`
sidecars with the user's audio file paths and `.current` pointers next
to the covers, the regenerate marker, and staging files. Only the image
signature check kept them out. Each folder now also names its covers by
their endings (cover store `.image`; Library thumbnails `.jpg`, `.png`
and `.image`; embedded artwork `.jpg`), so those files are refused by
name before anything is opened.

The provider checked one open of the file and served another. It now
opens the resolved file once with O_NOFOLLOW (and O_CLOEXEC from API
27), checks that descriptor with fstat for a regular file and pread for
an image signature, and serves a dup of that same descriptor; getType
reads its type the same way. The signatures are written as byte values,
so the source stays ASCII.
2026-10-30 18:53:55 +07:00
zarzet 40e55df0d4 fix(player): look for the cover provider again after a failure
The browser kept the first cover provider lookup for the life of the
process. BrowserCoverProvider.load caught only platform errors, so any
other error stayed in the cached future and made every later children
and search call throw; a lookup that answered null left local covers out
until the process ended.

load now answers null on any error, and the browser keeps only a found
provider: a call without one shows no local covers and the next browse
looks again (concurrent calls still share one lookup). The root tabs no
longer wait for the lookup and the store warm-up, which they do not
need; they start it so the list opened next finds it ready.
2026-10-30 18:53:55 +07:00
zarzet 7d5bbd306b fix(player): show local covers in Android Auto browse lists
_browserArt passed only web covers, as a car cannot open the app's own
files, so Library thumbnails, cover store files and embedded artwork
showed no cover in the car's lists.

Browse items now name a local cover inside one of the cover provider's
folders by its content:// URI, built from the path alone so the same
file always gets the same URI and the car's cache keys stay stable. A
network:// cover maps through CoverStore.indexedFile (index only, no
fetch or file IO), and a song shows the stored cover its playing item
would (CoverStore.songCover). Web covers pass as before; loopback URLs,
temporary files, covers outside the folders and every local cover on
platforms without the provider stay out. The playing item and
audio_service are unchanged.
2026-10-30 18:53:55 +07:00
zarzet 8b36e856ef feat(android): serve cover files to media browsers read-only
Android Auto loads browse item artwork from the item's icon URI in its
own process, so it cannot open the app's private cover files and local
covers were left out of every browse list.

CoverContentProvider serves them as content://<applicationId>.covers/
<folder>/<file>. A car cannot hold a permission, so the provider is
exported, and in exchange it only reads: openFile accepts mode "r" only,
insert/update/delete throw, query lists nothing. CoverProviderFiles
resolves a URI to a file only when its path is an allowed folder name
and a plain file name, the canonical file sits directly in the
canonical folder (no "..", encoded "/" or symbolic link out), and it is
a regular file starting with a known image signature.

The allowed folders are the ones browse lists name: the cover store
(files/covers), Library thumbnails (files/library_covers) and embedded
artwork extracted from downloads (cache/embedded_cover_previews). The
covers channel hands Dart the authority and folder paths, registered on
the shared engine so a car-started engine has it too.
2026-10-30 18:53:55 +07:00
zarzet 08d524eba4 fix(covers): keep a Subsonic cover path while its image is unchanged
The daily check rewrote subsonic_<hash>.image in place when no .current
pointer existed, so decoded sizes and the home-screen widget key kept
showing the old image after the server changed it. A forced refresh went
the other way and moved even an unchanged image to a new path, which
dropped every decoded size and rewrote Library rows for nothing.

The fetched bytes are now compared with the published file: the same
image only updates the modification time and keeps its path, a changed
image always gets a new path behind the .current pointer.
2026-10-30 17:47:54 +07:00
zarzet 64c5d3c433 refactor(covers): normalize statistics covers only where rows are read
ListeningTrack.fromRow already normalizes and sanitizes every stored
cover, so artist artwork and Rewind album covers use the track's
artwork as it is. ListeningSummary.fromRows has no app caller and is
marked for tests. The On repeat replay check tests PlayableMedia and
the cover store, so it moves to the cover store tests.
2026-10-30 16:09:33 +07:00
zarzet b7e18461eb refactor(link): keep the sync protocol free of the cover store
The history sync wire format imported cover_store.dart, with
path_provider and the network storage service, for one loopback check.
The check is now isLoopbackHost in cover_art_utils.dart, which both
durableCoverReference and linkSyncRemoteArtwork use. Same results.
2026-10-30 16:09:33 +07:00
zarzet 644cb29056 fix(covers): show the window's cover on the Rewind first song and replay
Both slides read the row of one day, so a day recorded by an older
build (a loopback or temporary cover, now read as none) showed the
placeholder even when the window's summary had the song's cover from a
later play. That is most of a first yearly Rewind after the update.
They now fall back to the summary's cover of the same song.
2026-10-30 16:05:57 +07:00
zarzet 751b3cd744 fix(covers): keep a song's recorded cover when its latest day has none
Summaries take a song's details from its latest day in the window, so
one short play without a known cover, such as a skip before an
embedded cover was read, hid the cover recorded on earlier days on the
statistics screen, Home and Rewind. The cover now comes from the
latest day that recorded one when the latest day has none; both rows
are read by primary key.
2026-10-30 15:48:33 +07:00
zarzet bb7dd1e833 fix(link): sync no loopback artwork from older statistics
History sync sends artwork as http(s) URLs, and statistics rows from
older builds hold loopback URLs of the author's cover proxy. A first
sync with a new peer copied those into the peer's statistics, where
they name the peer's own loopback server instead. Sent and received
artwork now drops loopback URLs, so peers store none.
2026-10-30 15:46:59 +07:00
zarzet 28ff305699 fix(home): show a network cover not stored yet in Continue listening
The resume card read only the item's artUri, which stays empty for a
network song whose cover the store does not hold, such as the first
launch after an update from a build that kept loopback URLs. It now
falls back to the item's cover reference, as the queue rows do, so
the cover is fetched once and shows.
2026-10-30 15:45:15 +07:00
zarzet e913f09d4a fix(player): keep stored loopback covers out of the Android Auto browser
Android Auto lists kept every cover starting with http. Collection
tracks loved from the player by older builds can hold a loopback URL
of the app's cover proxy, which a car cannot load and which named a
route of an earlier run. The browser now leaves those out like local
files.
2026-10-30 15:45:15 +07:00
zarzet e33d2d7089 fix(covers): keep temporary player covers out of Loved and recents
A song loved from the player without a Library record stored the
item's artUri as its collection cover, and an album or artist opened
from the player recorded its cover in recents. Older builds put
loopback URLs there; a tag cover the store could not keep still shows
from a temporary file on that play. Both writers now store only
covers that outlast the run, through durableCoverReference.
2026-10-30 15:38:42 +07:00
zarzet cd66e168f9 fix(covers): read stored statistics covers as durable references
Listening statistics rows from older builds hold loopback URLs and
temporary files that no longer load, so the statistics screen, Home
and Rewind showed broken covers. Rows are read through one
ListeningTrack.fromRow, which reads those as no artwork, so the
fallback shows until the song plays again.

A play whose cover is not known yet no longer erases the stored cover
of that day, and a write never stores a loopback or temporary cover.

Artist artwork and Rewind album covers dropped network:// references
because normalizeCoverReference rejects them; they now read through
normalizeStoredCoverReference, which keeps them without changing what
other stores accept.
2026-10-30 15:36:00 +07:00
zarzet aab8e73b48 fix(covers): keep a stored tag cover when a read has none
A tag read without a cover dropped the song's stored tag cover. For a
Subsonic song played from the Library that cover is the server's, and a
failed cover request also reads without one (and is remembered for five
minutes), so the playing song and the lock screen lost their cover on a
passing failure. A stored tag cover now stays until the store trims it:
a picture removed from a network file's tags lingers a while, which is
better than losing a cover the server still has. The store's forget
goes with it.

A metadata event whose song left the queue during the read threw, and an
older event's read could still store its cover after a newer one's. Both
now stop before touching the store.
2026-10-30 15:19:26 +07:00
zarzet cc3613ccff fix(covers): keep desktop covers fresh and drop removed tag covers
The cover read with a Subsonic song's tags is the server's own cover,
the one the song's network reference names. Keeping it again as a tag
cover made that copy win once the phone had played a desktop song, so a
cover changed on the desktop never reached the phone: the refresh
checks the network reference, and songs with a known tag cover skip it.
Subsonic songs with a network reference now keep only that reference,
which also stores each Link cover once and lets statistics keep a
reference the store can fetch again.

A tag read that finds no cover now drops the song's stored tag cover, so
a picture removed from the tags gives way to the folder cover as it did
before covers were stored. A metadata event updates the queue once: the
tag cover goes into the replaced entries instead of a separate update.
The Home resume item drops a loopback or temporary cover of an earlier
version, as a restored session does.
2026-10-30 15:07:30 +07:00
zarzet aad187c4d0 fix(covers): show a known tag cover and fetch changed covers on use
A network song with both a folder image and a cover in its tags showed
the folder image on every play once it was stored, unlike the Library.
The cover from the tags now wins once read: it is stored under the
song's cover reference, which a later play finds in the store's index,
so the item shows it from the first emission without flashing the
folder image. The folder image shows only while no tag cover is known,
and a late or changed folder cover no longer replaces a tag cover. The
session keeps neither file; statistics keep the reference of the cover
shown.

Covers a server reported changed are no longer fetched at once. A
desktop library job reported every song it touched, and each fetched
its cover, queued or not and stored or not. The store now marks the
cover stale and checks it on its next use, so only the playing song and
the next three fetch. The same mark drops the wait after a failed fetch,
so a Link reconnect retries the covers that failed while the desktop was
away instead of waiting out the store's minute.

A network:// artwork, as listening statistics keep for Home to play,
is the song's cover reference: the item shows its stored file and never
the network:// string, which the lock screen cannot load. Restored
sessions drop loopback and temporary covers of older versions, and the
temporary preview rule matches the preview folder, not a file name. A
tag cover the store could not keep shows on that play only.
2026-10-30 14:44:25 +07:00
zarzet 7bf3d5ee6b refactor(link): share the desktop cover reference
The resolver and the remote's metadata subscriber each built the cover
reference of a desktop song. The cover store keys covers by that exact
string, so one helper builds it for both and the forms cannot drift.
2026-10-30 14:44:25 +07:00
zarzet c650d705af fix(player): fetch network covers when an AutoMix starts a song
An AutoMix transition showed a stored cover, but a cover not stored yet
was only fetched if an earlier load had fetched it ahead, so after a few
mixed songs in a row a network song could stay without one. The
transition now fetches the new song's cover and the next three, as a
gapless start does.
2026-10-30 14:44:25 +07:00
zarzet 9b6854f3c4 feat(covers): show stored network covers in cover widgets
Cover widgets, precaching and palettes saw a network:// cover as a form
without an image. coverFilePath now answers it with the file the cover
store's index names, without file IO, so they show a stored cover as a
local file. A cover widget given a network cover the store does not
hold yet fetches it once through the store, within its fetch limit, and
builds again when it lands. Queue rows whose cover is not stored yet
show it that way.
2026-10-30 14:44:25 +07:00
zarzet 197cfc0d19 fix(network): play folder covers by reference
Playing a folder resolved its cover image to a loopback URL before
playback began and passed it as the songs' artwork, a URL that named the
cover for this run only, even for Subsonic songs whose own cover
differs. The songs already carry the cover as networkArtworkSource,
which the player now shows from the cover store, so the screen passes
only that and starts playback without the extra request.
2026-10-30 14:44:25 +07:00
zarzet d36298c1af fix(link): show stored covers on mirrored playback
The desktop and phone remotes resolved each queued song's network cover
through the loopback proxy, a new URL per lookup, for every row of a
queue up to 500 songs long. The items now show the cover store's file,
the same on every update, and carry the reference as
extras['artworkRef'].

Only the playing song and the next three fetch their covers; other rows
fetch theirs once they show. A failed cover is tried again after a
reconnect, as before. When the desktop changes a song's file, its cover
is fetched again at once, and a cover the store replaced shows on the
items with it.
2026-10-30 14:44:25 +07:00
zarzet c5502d4339 fix(player): show stored network covers on every play
Each play resolved a song's network cover through the loopback proxy,
which hands out a new URL per call. The first item had no cover, every
play showed a different URL, the lock screen and Link Now Playing saw
the cover change, and listening statistics recorded a URL that was dead
after the run.

Items now show the file the cover store holds for the cover from their
first emission, the same file on every play, and carry the reference as
extras['artworkRef']. A cover not stored yet is fetched without holding
up the audio and shows on the song and its queue entries once it lands,
the covers of the next three songs are fetched ahead for skips and
gapless starts, and a cover the store replaced shows at once. A restored
session and the Home resume item read the store's index first.

The tag cover a network metadata read leaves in a temporary file is
copied into the store before the session keeps it. Statistics record
the cover reference, or the artwork only when it lasts. The store's
index is read at startup and trimmed once a launch.
2026-10-30 14:44:25 +07:00
zarzet 079364656b feat(covers): look up, adopt and refresh stored covers
Playback needs a stored network cover while it builds a MediaItem, so
indexedFile answers from the in-memory index without file IO. adopt
copies a cover that reached the device another way, such as the tag
cover a network metadata read leaves in a temporary file, into the store
under a reference derived from the song (songCoverReference), named by
its bytes like a fetched cover. refresh fetches a cover again at once
when its server reports a change, instead of waiting a day for the
recheck.

durableCoverReference keeps only cover strings that outlast the run:
loopback URLs and files in the system temporary directory or the known
temporary cover folders are dropped, so statistics never record them.
2026-10-30 14:44:25 +07:00
zarzet fcf5c60ec6 test(covers): cross-check the document slot and steady the marker test
The document scan slot test only compared the stem with the function that
computes it. A new test writes a thumbnail through the Rust scan's
cache_cover and expects library_cover_slot to find that file for the same
key, then checks that the newer of two current siblings wins.

The forced-scan test compared marker mtimes 20 ms apart, which can flake
on filesystems that store whole seconds; it now checks that each forced
scan rewrites the marker's contents. The padded ID3 cover test reuses the
shared backend and ID3 helpers.
2026-10-30 14:21:07 +07:00
zarzet 991f2c539e fix(library): match cleared library covers by folder name
Clearing library covers marked rows whose cover_path started with Dart's
spelling of the folder. Scans store their own spelling: the canonical
/data/data path on Android 7 to 10, where /data/user/0 is a symlink, and
canonical backslash paths (possibly \\?\) on Windows. There no row was
marked, so local covers stayed broken until a forced rescan.

Rows are now matched by a library_covers path segment with either
separator; every file in that folder was just deleted, so each such row
is broken. The update also retries a busy writer before it begins, so a
running native scan no longer leaves the rows unmarked after the files
are gone.
2026-10-30 14:19:48 +07:00
zarzet 757bb14e65 fix(covers): name untimed embedded previews by their content
A source without a modification time always published its preview to
v2_<path hash>_0.jpg. After an in-app cover edit (invalidate, then extract
again) the new cover landed on the same path, so ImageCache kept showing
the old decoded cover in the metadata screen, Library and player.

Untimed previews are now named v2_<path hash>_0_<content hash>.jpg from a
SHA-256 of the extracted bytes: an unchanged cover keeps its path across
memory misses, an edited one gets a new path, and the existing variant
cleanup removes the previous file. Publishing also no longer deletes the
target before the rename, which already replaces it atomically, so a
reader never finds the preview missing.
2026-10-30 14:17:27 +07:00
zarzet 97bb845df5 fix(library): rescan local songs after clearing library covers
Clearing library covers in Settings deleted every file while Library rows
kept naming them. Network songs recover, since their scan reads a song
again when its cover file is gone, but local and document songs are
skipped by an unchanged timestamp, so their covers stayed broken until a
full rescan despite "Will re-extract on next scan".

The clear now also lowers the audio metadata scan version of local rows
whose cover was in that folder to the lyrics version. The incremental
snapshot then reports those files as changed once, so any next scan
extracts the covers again under the same names, which also brings back
the covers that playlists and sessions name. Lyrics filters are unchanged
meanwhile.
2026-10-30 14:15:10 +07:00
zarzet 4855b1a73f fix(covers): keep embedded previews of untimed sources on disk
When a source had no modification time (some document providers), its
embedded cover preview went to a new systemTemp/download_cover_preview_*
folder and was deleted as soon as the 180-entry memory cache evicted it,
even while the player or the saved session still pointed at it.

Such previews now go to the existing embedded_cover_previews folder under
one durable name (v2_<path hash>_0.jpg). They are still extracted again on
each memory miss, since a disk copy cannot be validated without a
timestamp, but evicting the memory entry never deletes a file: only the
disk budget, a refresh that replaces the preview, invalidate and the
manual clear do.
2026-10-30 14:15:10 +07:00
zarzet 4bb348f843 fix(library): keep cover files that other stores still name
The cover prune after a full scan treated a library_covers file as in use
only when library.cover_path named it. Playlists, favorites, the saved and
dismissed playback sessions, recent items, the download queue, listening
statistics and download history (including Link save offline copies) copy
those paths, so their covers broke after the next full scan.

The prune now also reads every such text column (read-only, in pages,
filtered with instr) and keeps the files they name, rebased onto today's
cover directory so file:// URIs and paths from an older iOS container
match. The names join the private native projection, so Rust still never
reads a live database and a failed read cancels the sweep.

A Subsonic cover kept by a reference also keeps its
subsonic_<hash>.image.current pointer, in Rust and in the Dart fallback;
before, the pointer was always deleted and the next scan fetched and
renamed the cover again.
2026-10-30 14:15:10 +07:00
zarzet 0b53ec64b8 fix(library): keep thumbnail paths across forced rescans
A forced rescan wrote every thumbnail into a new library_covers/full_scan_*
folder, so all stored cover paths changed at once. It did that to bypass
reuse of possibly wrong cached thumbnails and stale decoded images.

With collision-free names, a forced rescan now writes the .regenerate
marker into library_covers itself: native scans extract every thumbnail
again under its existing name, and the decoded image cache is cleared once
the rescan is indexed. Playlists, sessions and statistics that copied a
cover path keep a valid file.
2026-10-30 14:15:10 +07:00
zarzet 338e9ba83c fix(covers): key library thumbnails by 128-bit SHA-256
Scan thumbnails were named by a 32-bit djb2 hash of "path|size|mtime" (or
the document key) and an existing file was reused without checking its
source, so two songs whose keys collided showed one cover. The Android
document scan had its own copy of the same hash.

Thumbnails are now named cover_<first 128 bits of SHA-256 of the key>, in
Rust for every scan and through library_cover_slot for the Kotlin document
scan, so reuse by name is safe. Rows that name older files keep working;
those files are not looked up again and are pruned once unreferenced.

A forced rescan can touch a .regenerate marker in the cover folder:
thumbnails older than it are extracted again under the same name instead
of being reused, and the newer of a .jpg and .png sibling wins.
2026-10-30 14:15:10 +07:00
zarzet e30e213ed3 fix(link): refresh playback and details after desktop file changes 2026-10-30 13:12:05 +07:00
zarzet 3960f1383f fix(network): keep SMB HEAD 416 framing and test rejected covers
An unsatisfiable Range on SMB sets content-length 0 only for GET again,
so a HEAD answers as it did before the cover read moved to the shared
opener. A new test rejects 24 covers (404, audio, HTML) over one host's
six pooled connections, which times out if downloadCover stops
discarding a rejected response.
2026-10-30 11:29:25 +07:00
zarzet 30ab1c4af9 fix(covers): fetch awaited covers before background rechecks
Background rechecks of stale covers and first-time fetches shared one
FIFO queue, so a scrolled grid could queue many rechecks ahead of the
playing song's cover. Waiting fetches a caller awaits now take the next
free turn before any queued recheck, and the turn is taken before the
store folder is created so queue order follows call order.

A recheck that finds changed bytes leaves the old file dated ahead of
the clock; warmUp and trim now rank a file dated more than a day ahead
as the oldest, so a restart picks the new file and a trim drops the
stuck one first. The constructor asserts a positive fetch cap, and the
cap test waits with a bounded poll instead of one event queue pump.
2026-10-30 11:29:25 +07:00
zarzet 8b9f687c57 feat(covers): cap cover fetches and back off longer from missing covers
Playback and display will ask the store for whole queues and grids.

- At most four covers are fetched at once (maxFetches); the rest wait
  their turn in order, so a burst does not queue past the HTTP pool
  and time out into a retry backoff.
- A cover the server does not have (NetworkMediaUnavailable) or whose
  bytes are not an image waits an hour before the next fetch instead of
  a minute, so a desktop's songs without art are not asked for every
  minute while they are shown. Transfer failures keep the one-minute
  delay.
- A stored cover dated more than a day ahead of the clock is checked
  again, as one more than a day old is.
- trim checks again that no fetch has taken up a name after reading its
  details, before deleting it.
2026-10-30 11:29:25 +07:00
zarzet b5e558bfdf fix(network): release cover connections and keep the proxy's 416 framing
Review of the direct cover read found two regressions.

- downloadCover parsed Content-Type with ContentType.parse, which throws
  on a malformed value such as an unterminated quote. The response was
  then never read or discarded, so it held one of the server's six
  pooled connections for good, the same pool audio playback uses.
  The mime type is now read without throwing, and any response whose
  body was not read is discarded, in downloadCover and in _serve. The
  opener also discards when its own header checks throw (the Subsonic
  contentType getter had the same hold before this unit).
- An SMB range that cannot be satisfied answered with an empty chunked
  body instead of the old Content-Length: 0. The 416 answer sets the
  length again.

A cover answer that will not change soon (404 or 410, a Subsonic error
document with either status, audio or video, too large, empty) now
throws NetworkMediaUnavailable, an HttpException, so callers can wait
longer before asking again. Declared audio and video types are refused
before any bytes are read. A pinned TLS server is covered by a direct
read test too.
2026-10-30 11:29:25 +07:00
zarzet f499e0b66c feat(covers): add a durable store for network covers
Network covers reach the app as a loopback URL that changes on every
resolve, so the cover cache, the image cache, palettes and the media
session miss each time, and the URL breaks once the route is evicted
or the process ends. CoverStore turns a cover reference into a durable
local file instead.

- A network:// cover is fetched once with downloadCover() into
  <support>/covers/<reference key>_<content key>.image. The same
  reference with the same bytes keeps one path across calls and runs;
  changed bytes give a new path, so caches keyed by path show the new
  image.
- cachedFile() answers synchronously from an index that warmUp() reads
  from disk, so the first frame can show a stored cover. Existing file
  paths and file:// URIs pass through; https stays with
  CoverCacheManager.
- Concurrent requests for a reference share one fetch, a failure waits
  a minute before the next attempt (an unreachable desktop is not
  asked once per queue row), and a cover older than a day is answered
  at once and checked again in the background. New bytes are reported
  on changes.
- Fetched bytes must start like a JPEG, PNG, GIF, WebP, BMP, HEIF or
  AVIF image and stay within 16 MiB; they are staged and renamed, so a
  failure leaves no file.
- trim() removes superseded and abandoned staging files, then the
  covers checked longest ago beyond 2000 files or 200 MiB. Any cover
  can be fetched again from its reference.

Nothing uses the store yet; playback and display move to it next.
2026-10-30 11:29:25 +07:00