mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 23:05:46 +00:00
fix(themes): serve the Theme Store from GitHub raw, not jsDelivr (#1051)
Theme assets (registry.json, theme CSS, thumbnails) were served from the jsDelivr CDN's mutable @main edge, which caches up to 12h. The registry is purged on every themes push so updates were offered promptly — but the theme CSS could still be served stale, so an update stored pre-update CSS under the new version label and no further update was offered to correct it (a freshly animated theme would install without its @keyframes). Fetch everything from GitHub raw (permissive CORS, ~5-min server cache), which is always current. jsDelivr is dropped entirely: our request volume does not need a CDN, and its only real upside here (high-traffic edge serving) does not apply, while its staleness actively caused the bug. Rename cdnUrl -> assetUrl to reflect the source.
This commit is contained in:
@@ -85,30 +85,13 @@ describe('fetchRegistry', () => {
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('force-refresh tries GitHub raw first', async () => {
|
||||
it('fetches from GitHub raw, never a CDN', async () => {
|
||||
const calls: string[] = [];
|
||||
vi.stubGlobal('fetch', vi.fn(async (url: string) => { calls.push(url); return okRes(reg('forced')); }));
|
||||
vi.stubGlobal('fetch', vi.fn(async (url: string) => { calls.push(url); return okRes(reg('fresh')); }));
|
||||
|
||||
await fetchRegistry({ force: true });
|
||||
expect(calls[0]).toContain('raw.githubusercontent.com');
|
||||
});
|
||||
|
||||
it('force-refresh falls back to jsDelivr when raw fails', async () => {
|
||||
const fetchMock = vi.fn(async (url: string) =>
|
||||
url.includes('raw.githubusercontent.com') ? failRes() : okRes(reg('cdn')));
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
|
||||
const r = await fetchRegistry({ force: true });
|
||||
expect(r.registry.generatedAt).toBe('cdn');
|
||||
expect(fetchMock).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('non-force load uses the CDN only (not raw)', async () => {
|
||||
const calls: string[] = [];
|
||||
vi.stubGlobal('fetch', vi.fn(async (url: string) => { calls.push(url); return okRes(reg('cdn')); }));
|
||||
|
||||
await fetchRegistry();
|
||||
expect(calls).toHaveLength(1);
|
||||
expect(calls[0]).not.toContain('raw.githubusercontent.com');
|
||||
expect(calls[0]).toContain('raw.githubusercontent.com');
|
||||
expect(calls[0]).not.toContain('jsdelivr');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user