fix: use JSON FurnitureData from gamedata
CI / check (push) Successful in 23s
CI / release (push) Skipped
CI / deploy (push) Successful in 42s

This commit is contained in:
Simo committed 2026-08-02 14:42:23 +02:00
1 parent c78f8812ad
commit ab43f5d63c
2 files changed
+23 -8

No files matched your search

+11 -1
View File
@@ -20,7 +20,7 @@ vi.mock("@/lib/services/site-settings", () => ({
siteSettings: { get: settingGetMock }, siteSettings: { get: settingGetMock },
})); }));
import { writeFurniData } from "./furni-data"; import { getFurnitureDataPath, writeFurniData } from "./furni-data";
describe("writeFurniData production mirror", () => { describe("writeFurniData production mirror", () => {
let tempDir: string; let tempDir: string;
@@ -60,4 +60,14 @@ describe("writeFurniData production mirror", () => {
JSON.stringify(data), 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"),
);
});
}); });
+12 -7
View File
@@ -9,20 +9,25 @@ import { siteSettings } from "@/lib/services/site-settings";
import type { FurniMetadata } from "@/lib/services/swf-to-nitro"; import type { FurniMetadata } from "@/lib/services/swf-to-nitro";
const LOCK_STALE_MS = 60_000; const LOCK_STALE_MS = 60_000;
const DEFAULT_FURNI_DATA_URL = "/gamedata/config/FurnitureData.json";
/** /**
* Resolve the FurnitureData file path from the admin setting * Resolve the FurnitureData file path from the admin setting
* `furni_data_url` (e.g. `/nitro-assets/config/FurnitureData.json5`) mapped * `furni_data_url`. The production `/gamedata` mount maps to the configured
* under the public/ directory. Falls back to the json5 path if the setting * Gamedata filesystem root; other relative URLs map under public/.
* is unset.
*/ */
export async function getFurnitureDataPath(): Promise<string> { export async function getFurnitureDataPath(): Promise<string> {
const url = const url =
(await siteSettings.get( (await siteSettings.get("furni_data_url", DEFAULT_FURNI_DATA_URL)) ??
"furni_data_url", DEFAULT_FURNI_DATA_URL;
"/nitro-assets/config/FurnitureData.json5",
)) ?? "/nitro-assets/config/FurnitureData.json5";
if (path.isAbsolute(url) && !url.startsWith("/")) return 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(/^\/+/, ""); const relative = url.replace(/^\/+/, "");
// The `relative` segment is admin-configurable so its concrete value is // The `relative` segment is admin-configurable so its concrete value is
// unknown at build time; without the hint Turbopack traces the entire // unknown at build time; without the hint Turbopack traces the entire