Fix startup, replace dead download sources, and fix audit findings #11

Merged
kleb merged 9 commits from fix/main-esm-output into main 2026-10-19 10:46:43 +02:00
Owner

This change makes the app start again. It also replaces the download sources that stopped working, and it corrects the audit findings.

Changes

Start and display

  • The main process bundle is ES module output again (out/main/index.mjs). The Vite 7 change made CommonJS output, so the app did not start.
  • The renderer uses one vendor chunk. The old chunk split made an import cycle, and the window stayed blank.

Download sources

  • The public Tidal and Qobuz gateways do not operate now. Some domains are parked, and some domains have no DNS. The song.link API is closed, and the Amazon service needs a CAPTCHA. This change removes Amazon, song.link and all public gateways.
  • Tidal finds the track by ISRC with one request (GET /v1/tracks?isrc=). A metadata search is the fallback. The stream comes from the Tidal account of the user, then from an optional user-run instance.
  • Qobuz searches by ISRC with signed requests. Qobuz downloads use a user-run instance only.
  • Settings > Source has fields for the two instance URLs. The main process reads the URLs from the settings and accepts https only, or http to localhost.
  • The availability check is one Tidal ISRC request.
  • Error messages tell the user what to do, for example "Not signed in to Tidal".

Downloads and queue

  • Stop stops all downloads, also during the Tidal to Qobuz fallback.
  • A new metadata fetch does not cancel other fetches.
  • Large files do not time out on slow connections (idle timeouts).
  • The queue push sends counts and changed items only.
  • The existing-file check uses a per-folder ISRC index.

Data safety

  • A Tidal login does not overwrite an unreadable token store.
  • Cache migrations are transactional. Only a corrupt cache database is moved aside.
  • Tags, covers and settings use atomic writes. Renames and moves do not overwrite other files.

Security

  • The auto-updater is removed. It pointed to a GitHub account that is not ours.
  • Electron fuses are on.
  • The SSRF guard blocks more private address forms.

Checks

  • bun run typecheck, bun run lint, bun run format:check: pass.
  • bun run test: 131 of 131 tests pass (21 files).
  • bun run compile: pass, no chunk cycle warning.
  • Headless run of the built app:
    • Spotify track, album, playlist, artist and search: pass.
    • Downloads through a mock user-run instance (Tidal and Qobuz): pass. Each file has tags, ISRC and cover.
    • Repeat download, download after Stop, missing setup and unknown ISRC: correct result.
  • Not tested: a stream through a real signed-in Tidal account.

Measurements

Item Before After
Artist page, 37 albums (live) 22.8 s 4.95 s
300 existing-file checks, 300 FLAC files 24.2 s about 0.55 s (0.15 s parse + 0.4 s change detection)
Queue push, 2000 items 694 KB 1.6 KB
debug() call about 10 µs 0.015 µs

Evidence

Settings > Source with the two instance URLs:

settings-source.png

Track view with the Tidal availability check:

track-tidal.png

Home page:

home.png

This change makes the app start again. It also replaces the download sources that stopped working, and it corrects the audit findings. ## Changes **Start and display** - The main process bundle is ES module output again (`out/main/index.mjs`). The Vite 7 change made CommonJS output, so the app did not start. - The renderer uses one vendor chunk. The old chunk split made an import cycle, and the window stayed blank. **Download sources** - The public Tidal and Qobuz gateways do not operate now. Some domains are parked, and some domains have no DNS. The song.link API is closed, and the Amazon service needs a CAPTCHA. This change removes Amazon, song.link and all public gateways. - Tidal finds the track by ISRC with one request (`GET /v1/tracks?isrc=`). A metadata search is the fallback. The stream comes from the Tidal account of the user, then from an optional user-run instance. - Qobuz searches by ISRC with signed requests. Qobuz downloads use a user-run instance only. - Settings > Source has fields for the two instance URLs. The main process reads the URLs from the settings and accepts https only, or http to localhost. - The availability check is one Tidal ISRC request. - Error messages tell the user what to do, for example "Not signed in to Tidal". **Downloads and queue** - Stop stops all downloads, also during the Tidal to Qobuz fallback. - A new metadata fetch does not cancel other fetches. - Large files do not time out on slow connections (idle timeouts). - The queue push sends counts and changed items only. - The existing-file check uses a per-folder ISRC index. **Data safety** - A Tidal login does not overwrite an unreadable token store. - Cache migrations are transactional. Only a corrupt cache database is moved aside. - Tags, covers and settings use atomic writes. Renames and moves do not overwrite other files. **Security** - The auto-updater is removed. It pointed to a GitHub account that is not ours. - Electron fuses are on. - The SSRF guard blocks more private address forms. ## Checks - `bun run typecheck`, `bun run lint`, `bun run format:check`: pass. - `bun run test`: 131 of 131 tests pass (21 files). - `bun run compile`: pass, no chunk cycle warning. - Headless run of the built app: - Spotify track, album, playlist, artist and search: pass. - Downloads through a mock user-run instance (Tidal and Qobuz): pass. Each file has tags, ISRC and cover. - Repeat download, download after Stop, missing setup and unknown ISRC: correct result. - Not tested: a stream through a real signed-in Tidal account. ## Measurements | Item | Before | After | |---|---|---| | Artist page, 37 albums (live) | 22.8 s | 4.95 s | | 300 existing-file checks, 300 FLAC files | 24.2 s | about 0.55 s (0.15 s parse + 0.4 s change detection) | | Queue push, 2000 items | 694 KB | 1.6 KB | | `debug()` call | about 10 µs | 0.015 µs | ## Evidence Settings > Source with the two instance URLs: ![settings-source.png](https://git.kleb.sh/attachments/5853146a-e5de-4b34-bb77-8e77018d0b75) Track view with the Tidal availability check: ![track-tidal.png](https://git.kleb.sh/attachments/eeed15dc-38a1-4364-8411-bac679983bca) Home page: ![home.png](https://git.kleb.sh/attachments/15fbc9e6-3a57-4be4-9122-f8ba6ce0eef4)
The Vite 7 downgrade made electron-vite fall back to a CJS index.js, so
package.json main (out/main/index.mjs) no longer existed and the app could
not start. Forcing format es also fixes require() of the ESM-only got/jose
and restores the analysis-worker.mjs path.
- Skip cover art when reading tags; header-only FLAC picture check
- Bound concurrent metadata cleaning; atomic MP3 tag writes
- Cap output filename and atomic temp name lengths
- Remux to an owned temp file; recurse the startup temp sweep
- Quarantine only corrupt cache DBs; transactional migrations
- Shared iTunes/MusicBrainz limiters, abort losing cover lookups
- Size-capped atomic cover writes; streamed spectrum decode
- Non-clobbering renames and filtered-track moves (EXDEV fallback)
- Strict custom Tidal API URL allowlist
- Cache verbose flag and batch log file writes
- Tidal: one /v1/tracks?isrc= lookup (search only as fallback, stops at
  the first ISRC hit); stream via the signed-in account, then an optional
  custom instance. Actionable sign-in error, 404/Retry-After handling.
- Qobuz: signed catalog search with web-player credentials; downloads
  only from a user-configured instance.
- Idle timeouts for whole-file media streams.
- Token store never overwrites an unreadable store.
- Spotify: batch discography album fetches, reuse first pages, token
  single-flight and 401 refresh, skip local playlist items.
- Per-request metadata cancellation; DASH segment cap; SSRF guard and
  exact-host limiter routing.
- Stop is final until an explicit start/resume (StartDownloadSession);
  main reports cancelled downloads and every UI Stop ends all loops
- Queue pushes carry counts + changed items via one renderer store;
  indexed queue lookups in main
- Per-request metadata fetch ids; batch queue cancels its own fetches
- Per-folder ISRC index for existing-file checks
- Crash reload cancels orphaned queued items, capped reloads
- Remove the auto-updater pointing at an unrelated GitHub account;
  enable Electron fuses
- Covers use the same output folder as tracks; File Manager loads on
  submit; log polling survives Clear; retry jobs pruned; real failure
  reasons; rate-limit durations parse and waits honor Stop; select-all
  checks visible tracks; latest analysis wins; editorial playlist hint
- Install-time icon script no longer rewrites the tracked favicon
Every public gateway is gone (parked domains, dead DNS, CAPTCHA) and the
song.link API was shut down. Tidal streams through the user's account
with an optional self-hosted instance as fallback; Qobuz downloads use a
self-hosted instance. Instance URLs live in settings (customTidalApi,
customQobuzApi) and are validated in main; renderer-supplied URLs are
ignored. Availability is one Tidal ISRC lookup. Caches close on quit.
Docs updated.
The react/vendor manualChunks split formed an import cycle (vendor ran
before React), leaving the window blank since the Vite 7 downgrade. Use
a single vendor chunk. Also: providers create the output folder only
right before writing (no empty folders on failed resolution), spacing
in Source settings, and the embedded-cover check label no longer says
FLAC only.
Collaborator

kReview review

Verdict: no findings

No findings to address across the reviewed diff.

This review did not check generated or vendored files: bun.lock.

kReview checked only the PR diff, metadata, and supplied repository context at a51e62801c. It reports only issues supported by this material.

Estimated cost: ~$6.24 total (6.0M in / 13.4k out); this run ~$1.25 (1.1M in / 2.5k out) / gpt-6.1-sol.

Run time: 6:00 total; this run 1:04.

<!-- codex-forgejo-review --> <!-- codex-forgejo-review-head:a51e62801c038865291d1cb411ddb323307ea86c --> <!-- codex-forgejo-review-comparison:v1:a6465d2998ca497770e6ed64518c12bccd8afbd9131edd542a69e58f0ddcf169 --> ## kReview review **Verdict:** no findings No findings to address across the reviewed diff. _This review did not check generated or vendored files:_ `bun.lock`. _kReview checked only the PR diff, metadata, and supplied repository context at `a51e62801c`. It reports only issues supported by this material._ _Estimated cost: ~$6.24 total (6.0M in / 13.4k out); this run ~$1.25 (1.1M in / 2.5k out) / gpt-6.1-sol._ _Run time: 6:00 total; this run 1:04._ <!-- codex-forgejo-review-state:eyJoZWFkU2hhIjoiYTUxZTYyODAxYzAzODg2NTI5MWQxY2I0MTFkZGIzMjMzMDdlYTg2YyIsImNvbXBhcmlzb25LZXkiOiJ2MTphNjQ2NWQyOTk4Y2E0OTc3NzBlNmVkNjQ1MThjMTJiY2NkOGFmYmQ5MTMxZWRkNTQyYTY5ZTU4ZjBkZGNmMTY5Iiwic3VtbWFyeSI6Ik5vIGZpbmRpbmdzIHRvIGFkZHJlc3MgYWNyb3NzIHRoZSByZXZpZXdlZCBkaWZmLiIsImZpbmRpbmdzIjpbXSwiY3VtdWxhdGl2ZUNvc3QiOnsidXNkIjo2LjIzNzkwMiwiaW5wdXRUb2tlbnMiOjYwMzEzNDIsIm91dHB1dFRva2VucyI6MTM0NTAsIm1vZGVsIjoiZ3B0LTYuMS1zb2wifSwiY3VtdWxhdGl2ZUR1cmF0aW9uTXMiOjM2MDE3NH0= -->
- The legacy Tidal default URL is dropped only for the Tidal setting, so a
  Qobuz instance on http://127.0.0.1:8000 works.
- The ISRC index fingerprints entries by size and mtime and re-reads
  replaced or retagged files (stats run in parallel).
- Discography albums are cached only when all track pages loaded.
Names over the 180-byte stem cap now end with an 8-char hash of the full
name, so long titles that differ after the cut no longer collide.
Earlier Electron releases already removed customTidalApi from settings
on load, so the legacy Go default can no longer be a stale value; drop
the sentinel. When the account and the custom instance both fail, the
error now reports both.
kleb merged commit 06e5e50d5d into main 2026-10-19 10:46:43 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kleb/SpotifFLAC!11
No description provided.