restore x-audio-duration, without the ffprobe

removing it was wrong: the mobile player stopped playing. nothing in the web
read the header and /meta already carried durationSec, so it looked dead. it
was not — it is a documented part of the contract and something depended on it.

the header is back and the ffprobe is not. the value is read from the album's
meta.json, which is the same number ffprobe produced (the indexer got it from
ffprobe at index time), cached per album and keyed on the meta file's mtime so
a reindex invalidates it. 1.5ms cold, 0.1ms warm, against 50ms warm and 315ms
cold for the process spawn.

first pass looked for meta.json beside the audio; it lives under the sidecar's
own cache root mirroring the relative path. uses metaFilePath now rather than
re-deriving it.

verified against a real file: header present and equal to meta, 304 on
whole-file revalidation, 206 on range with a matching etag.
This commit is contained in:
2026-08-19 15:26:39 +00:00
parent 2a70bc18d7
commit 0e08aefad9
2 changed files with 64 additions and 12 deletions
+11 -5
View File
@@ -33,14 +33,20 @@ Byte-range streaming so the player can **seek without downloading the whole file
| No `Range` | `200` | `Content-Type`, `Content-Length`, `Accept-Ranges: bytes`, `ETag`, `Cache-Control` |
| With `Range: bytes=…` | `206` | `Content-Range`, `Content-Length`, `Accept-Ranges: bytes`, `Content-Type`, `ETag` |
- **`X-Audio-Duration` is GONE** (2026-08-19). It cost an `ffprobe` per file on the first request —
measured at 50ms warm, 315ms cold, paid before the first byte — to report a number the indexer had
already written into `meta.json`. **Read `durationSec` from `/meta` instead**, which every client
already fetches to build its queue.
- **`X-Audio-Duration` still ships, and no longer costs an `ffprobe`** (2026-08-19). It used to spawn
one per file on the first request — measured at 50ms warm, 315ms cold, paid before the first byte.
It is now read from the album's `meta.json` and cached per album: 1.5ms cold, 0.1ms warm, and the
same number, because the indexer got it from ffprobe too.
It was briefly removed outright, on the reasoning that nothing in the web read it and `/meta` already
carried `durationSec`. The mobile player stopped playing, so it is load-bearing for at least one
client and stays in the contract. New clients should still prefer `durationSec` from `/meta` — it
arrives with the queue, before the first stream request.
Absent when the album has not been indexed, exactly as it was absent when ffprobe failed.
- **`ETag`** is `mtime-size` in base36. A whole-file request with a matching `If-None-Match` answers
`304`; a Range request never does, because a 304 would answer a question about part of a file with a
statement about all of it.
VBR MP3s. No need to scan the file.
- Errors: `400` invalid/missing path · `404` not found · `416` bad range.
```