reindex-music looked one level too deep and reported the sidecar down

It read `process.env.DATA_PATH ?? cwd/data`. DATA_PATH stopped being an env var on 2026-08-13, when
the install layout became something derived from the working directory rather than configured — so run
from the repo this looked for platform/data/music/.server, which is one level too deep, found nothing,
and said the sidecar was not running.

Imports DATA_PATH from the platform instead, so there is one derivation rather than a copy that fell
behind. Verified it resolves to /home/pastilhas/officer-dev/data.

Also corrects the usage line: the script moved into this plugin and the header still said
`bun scripts/reindex-music.ts` from the platform repo.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-21 03:39:01 +00:00
co-authored by Claude Opus 5
parent efc9581889
commit 9f06297c64
+10 -3
View File
@@ -1,15 +1,22 @@
#!/usr/bin/env bun
/**
* Trigger the music library index on the officer-music sidecar and follow its progress live,
* ending with a summary report. Run from the platform repo: bun scripts/reindex-music.ts
* ending with a summary report. Run from the platform repo:
*
* It reads the sidecar's port from DATA_PATH/music/.server (written by the sidecar on startup) and
* bun plugins/music/scripts/reindex-music.ts
*
* It reads the sidecar's port from `<data>/music/.server` (written by the sidecar on startup) and
* consumes its /reindex/stream SSE endpoint — the same stream the app subscribes to.
*
* The data root comes from the PLATFORM, not from an env var. This read `process.env.DATA_PATH ??
* cwd/data` and DATA_PATH stopped existing on 2026-08-13, when the install layout became something
* derived from the working directory rather than configured. Run from the repo it looked in
* `platform/data/music/.server`, which is one level too deep, and reported the sidecar as not running.
*/
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { DATA_PATH } from '@@/data-path';
const DATA_PATH = process.env.DATA_PATH ?? join(process.cwd(), 'data');
const PORT_FILE = join(DATA_PATH, 'music', '.server');
type Progress = {