Everything the plugin is, moved out of officerdev/platform on 2026-08-15 — 41 files, unchanged from the tree they left. manifest.ts identity, one permission, ffmpeg/ffprobe declared api/ the sidecar proxy; the prefix comes from mountPrefix() sidecar/ the whole /api/music contract — indexing, streaming, per-user state db/ music_favorites, _playlists, _playlist_items, _now_playing web/ panels, layout, and the player: engine, bar, lyrics, favourites cliamp/ the second playback path, parked — not working, kept deliberately widgets/ the dashboard widget, parked — plugins cannot contribute widgets assets/ icon.png, the dock tile scripts/ the reindex CLI PLUGIN.md is the design record: what moved, what stayed, what broke, and why. MUSIC_API.md is the contract the phone and tablet apps speak, and the reason the sidecar's HTTP shape is not free to change. ── It does not build here, and that is the point ── The platform resolves `hooks/useClient`, `officerdev`, `officerdb/db` and `@@/*` through the workspace links in its own node_modules. Measured from this directory, outside the platform checkout, every one of them fails to resolve — 7 imports in the backend, ~29 in the frontend. So this repository is the source of truth, not yet a buildable unit. Making it one means the host API becoming something a plugin can depend on rather than something it reaches into. That is the next problem, and having the code here is what makes it unavoidable rather than theoretical. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { reindexFull } from './indexer';
|
|
|
|
// Nightly full-from-scratch reindex at 3am (server-local time). Uses reindexFull, so it builds into a
|
|
// fresh slot and atomically swaps it in only on success — the live index is never disrupted mid-build.
|
|
// Self-scheduling (a fresh setTimeout each night) rather than setInterval, so it always fires at 3am
|
|
// regardless of drift.
|
|
|
|
const REINDEX_HOUR = 3;
|
|
|
|
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
|
|
function msUntilNextHour(hour: number): number {
|
|
const now = new Date();
|
|
const next = new Date(now);
|
|
next.setHours(hour, 0, 0, 0);
|
|
if (next <= now) next.setDate(next.getDate() + 1);
|
|
return next.getTime() - now.getTime();
|
|
}
|
|
|
|
export function startNightlyReindex(): void {
|
|
const schedule = () => {
|
|
const ms = msUntilNextHour(REINDEX_HOUR);
|
|
const at = new Date(Date.now() + ms);
|
|
console.log(
|
|
`[music] nightly full reindex scheduled for ${at.toLocaleString()} (in ${(ms / 3_600_000).toFixed(1)}h)`,
|
|
);
|
|
timer = setTimeout(async () => {
|
|
console.log('[music] nightly full reindex starting');
|
|
try {
|
|
await reindexFull();
|
|
} catch (err) {
|
|
console.error('[music] nightly full reindex error:', err instanceof Error ? err.message : err);
|
|
}
|
|
schedule(); // reschedule for the following night
|
|
}, ms);
|
|
};
|
|
schedule();
|
|
}
|
|
|
|
export function stopNightlyReindex(): void {
|
|
if (timer) {
|
|
clearTimeout(timer);
|
|
timer = null;
|
|
}
|
|
}
|