diff --git a/src/lib/services/furni-data-paths.test.ts b/src/lib/services/furni-data-paths.test.ts index 622d9fe6..ba951a86 100644 --- a/src/lib/services/furni-data-paths.test.ts +++ b/src/lib/services/furni-data-paths.test.ts @@ -20,7 +20,7 @@ vi.mock("@/lib/services/site-settings", () => ({ siteSettings: { get: settingGetMock }, })); -import { writeFurniData } from "./furni-data"; +import { getFurnitureDataPath, writeFurniData } from "./furni-data"; describe("writeFurniData production mirror", () => { let tempDir: string; @@ -60,4 +60,14 @@ describe("writeFurniData production mirror", () => { JSON.stringify(data), ); }); + + it("resolves the default JSON file from the production Gamedata root", async () => { + settingGetMock.mockImplementation( + async (_key: string, fallback: string | null = null) => fallback, + ); + + await expect(getFurnitureDataPath()).resolves.toBe( + path.join(tempDir, "Gamedata", "config", "FurnitureData.json"), + ); + }); }); diff --git a/src/lib/services/furni-data.ts b/src/lib/services/furni-data.ts index f5e114e2..39152390 100644 --- a/src/lib/services/furni-data.ts +++ b/src/lib/services/furni-data.ts @@ -9,20 +9,25 @@ import { siteSettings } from "@/lib/services/site-settings"; import type { FurniMetadata } from "@/lib/services/swf-to-nitro"; const LOCK_STALE_MS = 60_000; +const DEFAULT_FURNI_DATA_URL = "/gamedata/config/FurnitureData.json"; /** * Resolve the FurnitureData file path from the admin setting - * `furni_data_url` (e.g. `/nitro-assets/config/FurnitureData.json5`) mapped - * under the public/ directory. Falls back to the json5 path if the setting - * is unset. + * `furni_data_url`. The production `/gamedata` mount maps to the configured + * Gamedata filesystem root; other relative URLs map under public/. */ export async function getFurnitureDataPath(): Promise { const url = - (await siteSettings.get( - "furni_data_url", - "/nitro-assets/config/FurnitureData.json5", - )) ?? "/nitro-assets/config/FurnitureData.json5"; + (await siteSettings.get("furni_data_url", DEFAULT_FURNI_DATA_URL)) ?? + DEFAULT_FURNI_DATA_URL; if (path.isAbsolute(url) && !url.startsWith("/")) return url; + if (url === "/gamedata" || url.startsWith("/gamedata/")) { + const gamedataRoot = await getGamedataRoot(); + if (gamedataRoot) { + const relative = url.replace(/^\/gamedata\/?/, ""); + return path.join(/*turbopackIgnore: true*/ gamedataRoot, relative); + } + } const relative = url.replace(/^\/+/, ""); // The `relative` segment is admin-configurable so its concrete value is // unknown at build time; without the hint Turbopack traces the entire