Commit Graph
206 Commits
Author SHA1 Message Date
zarzet a2c01d72bf feat(library): use folder images as covers for songs without one
Large libraries often keep album art as cover.jpg or folder.jpg beside
the songs instead of embedding it, so those songs showed no cover.

When a song has no embedded artwork, local scans now fall back to an
image in its folder: cover, folder, front, album, albumart (jpg, jpeg,
png, webp), case-insensitive, ignoring hidden and AppleDouble files. A
disc folder (CD1, Disc 2, ...) without one uses its parent's image.
Embedded artwork always wins.

The Rust path scan (desktop, iOS, Android file paths) picks the image
from the directory listing it already makes and hands it to the
workers; the thumbnail key includes the image path, size and mtime, so
a replaced image gets a new thumbnail. CUE tracks get the same
fallback. The Android SAF scan picks the image from its own listing
through new FFI helpers and makes each image into a content-named
thumbnail once per scan.
2026-11-08 15:54:58 +07:00
zarzet a1e8e37266 chore(deps): update Rust dependencies
Bump the exact pins that had semver-compatible releases: aes 0.9.4,
mdns-sd 0.21.7 and zip 9.4.1. Refresh Cargo.lock within the existing
requirements (cc, flate2, log, smallvec, toml, wasm-bindgen and other
transitive patch releases).

Every other direct dependency is already at its newest release. The
vendored patches, the Unicode 15 pins, uniffi, rquickjs, scraper and
html5ever are unchanged. Rust 1.99.1 remains the newest stable toolchain.
2026-11-07 18:54:53 +07:00
zarzet bbd4332653 feat(lyrics): save AI translation word timing
A saved AI translation kept only its line text, so the word-synced
translation went back to line sync once the AI cache was gone. It now
travels with the lyrics as an [x-translation-words:<ms>:<base64 JSON>]
tag, the same JSON as [x-romaji-words].

- Both lyrics parsers read the new tag, keep it only when its words spell
  the line's translation, and move it with the file's offset. The native
  parser sends translationWords only for lines that have it, so the shared
  goldens stay as they were; a new golden covers the tag.
- Saving into the song file or a .mlrc file writes it, a new translation
  drops timing kept for the old one, and the lyrics editor moves it with
  its line like pronunciation timing.
- A shown translation whose timing the file lacks counts as unsaved, so
  the save action and automatic saving add it.
- Older versions drop the tag as an unknown x- ID tag.
2026-11-07 15:31:38 +07:00
zarzet d290a4cee3 fix(cast): stop treating every TV media error as fatal
Android failed the song on any media error message from the receiver,
even if the TV kept playing. The app then showed "TV could not play this
audio file", stopped following the position and stopped sending Pause.

Fail only when the receiver stops with an error, as the iOS and desktop
sender already does. Media errors now reach the app log with their reason
and code on every platform, so a failed seek can be traced.
2026-11-07 01:22:35 +07:00
zarzet 04e8f6cf10 fix(android): reject unknown Direct USB packet timing 2026-11-06 20:52:21 +07:00
zarzet 969ee435e2 fix(lyrics): keep spaces after word closing timestamps
Enhanced LRC can close a word before the space that follows it, as in
<00:01.00>First<00:01.50> <00:02.00>second. Both parsers treated that
space only as an end time and dropped it, so word-synced lines lost the
gaps between words.

Append the separator to the previous word in the Dart and Rust parsers,
and keep the first closing timestamp when more than one follows.
2026-11-05 19:17:53 +07:00
zarzet 20e5b550d9 chore: neutralize UI terminology and clarify code comments 2026-11-04 22:53:56 +07:00
zarzet 3ace5b1988 fix(nas): accept format hints in metadata proxy URLs 2026-11-04 15:09:08 +07:00
zarzet 84b1ab8c6f feat(cast): add a Rust Google Cast sender and media server
New crate mornye-cast:
- Cast v2 sender over TLS (launch the Default Media Receiver, load,
  play, pause, seek, volume, heartbeat, status snapshots in the shape
  the Android plugin already emits).
- mDNS discovery of _googlecast._tcp receivers.
- HTTP media server on the route to the receiver: files with range
  requests, and a relay for http(s) sources such as network songs.

CastService exposes one call(method, args) surface. The mobile crate
wraps it as the UniFFI object CastBridge with polled events, and the
desktop crate dispatches it as castCall with castStatus and castDevices
events.

The server replaces the Dart one: on a 100 MB file it read 1.3 to 1.7x
faster, used less CPU and about a third of the memory, and does not
share the UI isolate.
2026-11-04 02:01:11 +07:00
zarzet ab7157aa0a perf(backend): migrate selected data jobs to Rust
Route file hashing, AI lyric reply parsing, cache statistics and Autoplay taste training through native workers. Preserve model persistence and isolated compatibility fallbacks, with native parity and full-route performance coverage.
2026-11-03 13:17:12 +07:00
zarzet 6e07941b35 feat(library): save network songs offline with independent copies 2026-11-03 03:18:14 +07:00
zarzet 39d3ba6c53 merge: sync reviewed pull requests from origin main 2026-11-03 00:44:44 +07:00
Keven Chantre cea54e3acc fix(windows): treat verbatim and plain paths as the same file
On Windows the desktop scanner resolves folders with fs::canonicalize,
so scanned songs are stored as `\\?\C:\...` (or `\\?\UNC\server\...`)
while downloads keep `C:\...`. Path match keys did not relate the two
spellings, so with the download folder added as a Library folder:

- every downloaded song was listed twice (the scanned row was never
  shadowed by its download), and
- Review Duplicates paired each download with its own scanned row, so
  removing the "duplicate" deleted the only copy of the file.

Path match keys now also include the plain spelling of a verbatim path,
in Dart and in the native Rust copy. Rows already stored get the missing
keys once when the Library and History databases open on Windows; rows
that already have them cost one indexed probe. No schema version change.
2026-11-02 12:41:31 +00:00
zarzet bdebceec5d perf(library): share Android thumbnail files by content
Use SHA-256 names for Android library artwork and migrate stored Library paths in resumable pages. Preserve legacy files until saved references release them. Host fixtures reduce twelve repeated thumbnails to two files and keep shared bytes unchanged when one song changes artwork.
2026-11-01 21:24:57 +07:00
zarzet 8dccb0582d fix(library): unify Windows extended path identities 2026-11-01 20:21:44 +07:00
zarzet d789c08630 perf(link): suppress idle state heartbeats and redundant pings
Send periodic player states only while connected and playing, keeping debounced changes and reconnect state delivery. Skip remote playback publication for download-only updates. Keep transport ping/pong liveness while paused and avoid a server ping after recent client traffic.

Negative controls observed four eliminated paused phone states per minute, three redundant download-driven playback events reduced to zero, and server ping suppression with client pings. All 104 scoped Dart tests and 114 Rust tests pass, with strict analysis, clippy and format checks.
2026-11-01 20:11:40 +07:00
zarzet 22c4f92a82 perf(library): reduce schema writes and repeated path migration
Bump Library to v21 and History to v16, add album artist indexes, and remove six Library and three History indexes whose seeks are served by existing queue indexes. Keep the named file-path index for released readers and synchronize native schema checks.

Persist the iOS container migration marker in the database transaction, exclude current paths, and bound Library and CUE reads to 256 rows. Repeat opens read one marker row. Test rollback, path keys, bookmarked sources and downgrade/reupgrade compatibility.

Four alternating 15,000-row host write pairs reduced median batch time from 3364.773 ms to 2782.200 ms (17.3 percent). Native staging now takes the shared History schema version.
2026-11-01 19:41:07 +07:00
zarzet af8f222971 fix(covers): preserve fresh thumbnail permissions when linking
Compare link candidates with the permissions of a normally created stage so a changed cached file cannot alter a new song cover's mode. Keep the copy fallback when they differ.

The new regression fails before this fix (0604 instead of 0644) and passes afterward. All three affected Rust crate tests, clippy, formatting, and diff checks pass.
2026-11-01 19:13:11 +07:00
zarzet 0f6436b907 perf(library): move the incremental scan delta instead of copying it
json! turns every value into to_value(&value), so building the delta
with json!({"scanned": tracks, ...}) serialized every scanned row into
a second copy (wrapping the rows in Value::Array inside json! copies
them too). The object is now built as a Map that takes the rows and the
deleted paths by value, in the same key order, so the JSON is
byte-identical.

Measured with a standalone serde_json 1.0.154 program (release, 20,000
rows shaped like scan rows, 15.2 MB of JSON): 35 to 37 ms and 62 MB of
extra peak memory -> under 0.1 ms and 0.1 MB, same output hash.
2026-11-01 19:13:11 +07:00
zarzet bb7a8cee99 perf(network): keep NAS tag covers the cache already holds
Every NAS tag read that found a picture rewrote the content-addressed
network_cover_<sha256>.image through write_atomic (sync_all, which is
F_FULLFSYNC on Apple), then listed and trimmed the folder, even when
the same file was already there, as it is for every further song of an
album. A file that still holds exactly the same bytes is now kept and
its mtime renewed, as the rewrite did, so the 32-file trim keeps it
among the newest; nothing is added, so the trim is skipped. A damaged
file under the name, or one a concurrent trim removed, is still
rewritten.

Measured on this Mac (release, 350 KB cover, 32 cached files): a repeat
call 4.9 to 8.9 ms -> 0.23 to 0.39 ms, most of it the SHA-256 that
names the file.
2026-11-01 19:13:11 +07:00
zarzet a934bd1b00 perf(covers): link identical Library thumbnails on desktop and iOS
Every song got its own thumbnail file even when an album's songs embed
the same picture, so a scan wrote and kept one 150 to 430 KB copy per
song. The in-memory thumbnail cache, which already reuses the resize by
content, now also records the file that holds the bytes. The next song
with the same picture hard-links that file into its own name (link a
stage name, then rename), but only while the file still holds exactly
those bytes, is current for the regenerate marker and has the expected
permissions; otherwise, or when linking fails, it writes the bytes as
before. Every name, its bytes and every stored coverPath stay the same.
Songs of one album hold the record until the first file is published,
so concurrent scan workers link instead of writing copies.

A new name keeps its inode's old mtime, so the Library cover prune now
counts a multi-link file from the newer of mtime and ctime (link(2)
updates ctime): the one-minute guard for background producers still
holds. Files with one name, which is every file on Android and Windows,
keep the mtime rule. Deleting a name never touches the others.

Android keeps one file per song (content-addressed names there are a
later unit) and Windows keeps copies too.

Measured (release, scan_timing_with_many_thumbnails, 1,000 songs over
100 pictures): 1,000 names on 113 to 120 files, 341 MB -> 38 to 40 MB
on disk; the scan time is unchanged (5.5 s). The extra files come from
the 8 MB in-memory cache evicting a picture before a lagging worker
reaches it.
2026-11-01 19:13:11 +07:00
zarzet b427049a8a perf(covers): flush scan thumbnails once per scan on Apple
Rust's sync_all is F_FULLFSYNC on Apple targets, a drive cache flush
that every Library thumbnail paid twice (file and folder), and the
device-wide flush does not overlap across scan workers. Scan workers
now publish thumbnails with a plain fsync(2), which still hands the
whole file to the drive before the rename gives it its final name, and
the scan flushes the thumbnail folder once with sync_all when its
workers finish (a drop guard covers failure and cancellation).

Only scan workers use the batch. Single reads, CUE sheets, cover exports
and downloads keep the full sync, and other platforms keep the current
publication. A power loss inside the scan window can at worst leave an
empty thumbnail, which is now treated as missing and extracted again.

Measured on this Mac (release, ignored test
scan_timing_with_many_thumbnails, 348 KB thumbnails): 1,000 songs over
100 album pictures 9.3 s -> 5.5 s; 1,000 distinct pictures 42.4 s ->
41.0 s, where the serialized resizes dominate.
2026-11-01 19:13:11 +07:00
zarzet 5d58a20e4a fix(extensions): enforce deadlines while waiting for the VM
Bound queue waits and retain operation ownership through VM cleanup. Abandoned queued operations never execute. The short-deadline regression previously waited longer than one second; Rust workspace tests and strict clippy pass.
2026-11-01 19:11:44 +07:00
zarzet 7335880d6d fix(downloads): preserve cross-provider recording identity
Handle contributor-only title annotations consistently, expose the source catalog to extensions, and retain provider availability failures.
2026-11-01 14:50:25 +07:00
zarzet b2eaf5ed45 fix(network): recognize WebDAV NAS addresses behind tunnels
Recognize an advertised LAN origin only when the WebDAV response identifies the requested collection unambiguously. Keep browsing and playback on the saved connection so tunnel access and HTTPS trust continue to apply.

Validation: 76 Flutter tests and 7 Rust parser tests passed. Dart analyzer, Clippy with warnings denied, formatter checks, and git diff --check passed. Includes HTTP and HTTPS transport fixtures and rejected ambiguous origins; the reporter's NAS still needs a retest.
2026-11-01 14:11:24 +07:00
zarzet e942117e9d fix(network): handle WebDAV HTTP listing variants
Read same-host WebDAV child paths advertised through another HTTP or HTTPS listener while retaining the configured transport origin. Accept successful property statuses without a reason phrase, and reject non-WebDAV documents instead of presenting empty folders.

Validation: 71 Flutter tests and 7 Rust parser tests passed. Dart analyzer, Clippy with warnings denied, formatter checks, and git diff --check passed. The reporter's NAS still needs a retest.
2026-11-01 00:57:02 +07:00
zarzet 4d53d7f75c perf(network): revalidate stale Subsonic covers with their ETag
The daily cover check downloaded every stale Subsonic cover in full
and compared it with the cached file byte by byte, although the Link
desktop (and many servers) send an ETag and answer If-None-Match with
304. The first rescan of a day fetched all 500 album covers of a Link
library at original size.

The ETag of a downloaded cover is now kept beside it in
<cover>.etag together with the image length. A stale check sends
If-None-Match; a 304 keeps the path and touches the modification
time, like an unchanged download did, without reading a body. A 200
follows the existing rules (same bytes keep the path, changed bytes
get a new path behind .current) and stores the new ETag. A forced
refresh, a validator for other bytes, older caches and servers
without ETags behave as before.

The validator survives restarts. The Library cover prune (Dart and
Rust) keeps it with a referenced Subsonic cover, as it keeps the
.current pointer, and the song metadata cover cache still keeps 32
covers, each with its ETag, instead of counting ETags as covers.
Older builds ignore the files and their prune removes them.
2026-10-31 22:07:30 +07:00
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 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 515cfaf231 fix(replaygain): recognize Opus gain tags consistently 2026-10-30 19:39:35 +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 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 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 1e620c750a fix(link): key extracted cover pictures by their audio file
The ETag and the resized copy of an embedded picture came from its
extracted copy in the temp cache: path, mtime and length. Once the cache
trimmed that copy (4000 files) or the OS purged the temp folder, the
picture was extracted again with a new mtime, so the same image got a new
ETag (clients downloaded it again) and a second resized copy that
stayed in the cache beside the first.

The stamp of an embedded picture is now the audio file's path, mtime and
length, which already named the extracted copy. Every id that resolves
to one image (album, artist or song id) still shares one ETag and one
resized copy. Cover files keep their stamp and their ETags.
2026-10-30 07:42:07 +07:00
zarzet 46b4f4fbc5 fix(link): fall back when a listed cover file is gone
getCoverArt resolved an id to a single source: a song's own cover file,
else its album's, else embedded pictures. When the listed file was gone
(a pruned or moved Library thumbnail, a stale export) it answered 404,
although the album's cover file or the picture embedded in the song
could still serve it. The phone then showed a placeholder.

The catalog now returns every fallback in order (the song's own file,
its album's file, then the songs that can embed a picture) and the
server serves the first one on disk. 404 remains for ids with none.
Responses, content types and ETags for covers that resolve today are
unchanged.
2026-10-30 07:42:07 +07:00
zarzet a73f63772d chore(deps): update Flutter, native and Rust dependencies 2026-10-30 01:29:33 +07:00
zarzet 274cfb765c fix(library): read Opus tags with large artwork 2026-10-30 00:32:53 +07:00
zarzet c833a24212 fix(downloads): handle unsupported exclusive renames 2026-10-30 00:32:07 +07:00
zarzet d58565d287 feat(library): suggest songs under albums, singles and playlists
Albums, singles and playlists, online and in the Library, end with
"Suggested songs": up to ten songs like the ones above that the collection
does not hold yet, each with a preview, an add button and a click or tap
that downloads it. On a user playlist the add button adds the song there
and it leaves the suggestions; elsewhere it opens the playlist picker.
Phones list the songs as rows, desktop in the page's song table.

Suggestions come from a new optional extension method, getRelatedTracks,
which extensions declare with the relatedTracks capability: it takes up to
three of the collection's songs and returns songs in the shape of search
results. The extension most seeds came from is preferred so it can use
their IDs. Without such an extension, the first metadata provider is
searched by the collection's artists. A refresh button starts from other
songs, and loaded suggestions stay for ten minutes.
2026-10-29 02:23:07 +07:00
zarzet 4b18a270dd fix(metadata): save animated artwork during re-enrichment 2026-10-29 01:48:14 +07:00
zarzet 0cc70070c5 fix(deezer): prefer playable releases for ISRC matches 2026-10-29 01:43:06 +07:00
zarzet aa788591a3 fix(library): hide CUE sources after a complete split
Publish all split tracks and their visibility rule atomically while preserving the original files and playlist rows. Keep the rule across rescans, restore originals when outputs leave the visible Library, and stabilize Android SAF identities and artwork caching.

Validation: 84 Flutter tests, 19 native Library tests, scoped analyzer, formatting checks, and Android Kotlin compilation passed.
2026-10-28 20:43:10 +07:00
zarzet 2ad05be4bd fix(metadata): keep WAV INFO and ID3 tags in sync 2026-10-28 00:26:47 +07:00
zarzet b41f0d3eb4 fix(desktop): handle LRC sidecars and percent paths safely 2026-10-27 17:20:11 +07:00
zarzet 1f12076765 feat(search): recognize songs playing nearby
A microphone button in the empty search field listens to the room and
names the song, on phones and desktop.

- The audio fingerprint and the Shazam request run in Rust behind a new
  recognize_song data job, so every platform shares one path.
- Listening sends the audio so far at 4, 8 and 12 seconds and stops at
  the first match; quiet or short clips are reported instead of sent.
- A match can be played from the library (by ISRC, then title and
  artist), searched in Mornye, or opened in Shazam. Recent matches are
  kept in a local history.
- Android asks for the microphone only when listening starts; iOS and
  macOS gain the microphone usage description and entitlement. The Linux
  package recommends pulseaudio-utils for capture.
2026-10-26 01:33:56 +07:00
zarzet 1780693f6d feat(rust): describe how songs sound from decoded windows
Add an audio_features native data job that reads one or two decoded
mono windows and returns a compact, versioned vector of 42 numbers:
tempo and its confidence, loudness and its spread, brightness,
rolloff, flatness, onset rate and flux, low/mid/high band shares,
key, mode and key strength, and 13 MFCC means and spreads. Silent or
too short audio yields no features. The job reuses the hi-res FFT and
the AutoMix tempo detector and checks for cancellation as it goes.
2026-10-25 23:36:14 +07:00
zarzet e0ab3c10ca merge: integrate reviewed Windows and extension fixes 2026-10-25 23:19:03 +07:00
zarzet d8660ba95f fix(extensions): preserve verification after challenge failures (#610) 2026-10-25 22:30:42 +07:00
zarzet bf8d50eb8d fix: improve playback responsiveness and resource lifecycles
Prevent stale transport and lyric updates, cancel abandoned requests, bound Link and Subsonic buffering, and preserve native audio lifecycle ownership. Add regression coverage for startup, search and transfer cleanup.
2026-10-25 15:15:52 +07:00
zarzet 099f6b65ae feat(link): serve song lyrics over the songLyrics extension
The desktop now answers OpenSubsonic getLyricsBySongId with the lyrics
a song's file embeds, else its .lrc sidecar, as line-level structured
lyrics, and advertises songLyrics. The entry also carries the stored
text as mornyeRaw, so the phone can keep word timing, voices and
backing vocals that the line-level shape drops.
2026-10-25 14:05:49 +07:00