From b84f0b0b18c2dfe34b25bd73a39c757167524302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Mon, 27 Jul 2026 16:07:39 +0000 Subject: [PATCH] =?UTF-8?q?music:=20/manifest=20is=20a=20pure=20read=20?= =?UTF-8?q?=E2=80=94=20never=20triggers=20a=20(re)build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reading the manifest (which every app refresh hits) used to call ensureIndexFresh(), kicking off a debounced rebuild — and after the CACHE_VERSION bump that meant a plain refresh could launch a full library rebuild. Make reads side-effect-free: /manifest now just returns the last completed index. Builds are explicit only (POST /reindex or the SSE stream); pick up disk changes by reindexing. Removes the now-unused ensureIndexFresh + lastBuildFinishedAt, and drops /manifest from the 30-min per-request timeout extension (both hops) since it no longer blocks on a build. Co-Authored-By: Claude Opus 4.8 --- src/servers/api/music/router.ts | 2 +- src/servers/sidecar/music/index.ts | 14 ++++++------ src/servers/sidecar/music/indexer.ts | 32 ++++++---------------------- 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/src/servers/api/music/router.ts b/src/servers/api/music/router.ts index 78d1f356..cced3f7e 100644 --- a/src/servers/api/music/router.ts +++ b/src/servers/api/music/router.ts @@ -93,7 +93,7 @@ musicRouter.all('/*', async (ctx) => { // A from-scratch reindex holds this proxied connection open for minutes with no bytes flowing, which // the main server's 60s idle timeout would drop. Extend it to 30 min for the build/progress endpoints // (Bun passes the server as Hono's env). Matches the sidecar's own per-request extension. - if (subpath === '/reindex' || subpath === '/manifest' || subpath === '/reindex/stream') { + if (subpath === '/reindex' || subpath === '/reindex/stream') { const server = ctx.env as { timeout?: (req: Request, seconds: number) => void } | undefined; try { server?.timeout?.(ctx.req.raw, 1800); diff --git a/src/servers/sidecar/music/index.ts b/src/servers/sidecar/music/index.ts index 5f720853..59196b6b 100644 --- a/src/servers/sidecar/music/index.ts +++ b/src/servers/sidecar/music/index.ts @@ -5,7 +5,6 @@ import { createSidecarConnector } from '../connect'; import { streamAudioFile } from './stream-audio'; import { reindexNow, - ensureIndexFresh, getIndexStatus, getManifest, albumVersion, @@ -34,8 +33,8 @@ const DATA_PATH = process.env.DATA_PATH ?? join(process.cwd(), 'data'); // // GET /stream?path= audio with Range→206 (Content-Range/Length/Accept-Ranges) // + `X-Audio-Duration` (seconds, ffprobe). 400/404/416. -// GET /manifest ensures a fresh index (debounced rebuild) then returns -// { version, generatedAt, albums: { "": { v, cover, tracks, disco? } } } +// GET /manifest pure read of the last completed index (NO build triggered) — +// { version, generatedAt, albums: { "": { v, cover, tracks, videos?, disco? } } } // GET /meta?path= album meta.json (IndexMeta). ETag: ; If-None-Match → 304. // GET /cover?path= compressed cover.jpg. ETag: ; If-None-Match → 304. // GET /poster?path=&file=