fix(nitro): normalise uploaded bundles so meta.image matches the texture
Gitea Actions Runner Test / test-job (push) Successful in 2s
CI / check (push) Successful in 39s
CI / tests-unit (push) Successful in 2m3s
CI / tests-integration (push) Successful in 2m7s
CI / tests-ui (push) Successful in 2m50s
CI / preflight (push) Skipped
CI / deploy (push) Failing after 1m45s
Gitea Actions Runner Test / test-job (push) Successful in 2s
CI / check (push) Successful in 39s
CI / tests-unit (push) Successful in 2m3s
CI / tests-integration (push) Successful in 2m7s
CI / tests-ui (push) Successful in 2m50s
CI / preflight (push) Skipped
CI / deploy (push) Failing after 1m45s
An uploaded .nitro was written to disk byte-for-byte, so a bundle from a third-party tool that ships a WebP member while still pointing spritesheet.meta.image at a .png was accepted and stored as-is. The client resolves the spritesheet through that pointer, so the result was a file that validates fine and then renders nothing. Re-write the bundle through createNitroBundle on import, which labels the member from the actual bytes and repairs the pointer. No texture is re-encoded, so the bytes stay identical, and the member keeps the base name it arrived with so `chair*2` colour variants that share the `chair` library are not renamed.
This commit is contained in:
1 parent
17de94d984
commit
306e209e29
4 files changed
+36
-153
No files matched your search
@@ -84,8 +84,19 @@ vi.mock("@/lib/services/furni-import", () => ({
|
||||
IMPORTED_PAGE_CAPTION_SAVE: "imported_furni",
|
||||
}));
|
||||
|
||||
const nitroBuilderMock = vi.hoisted(() => ({
|
||||
createNitroBundle: vi.fn((json: object) =>
|
||||
Buffer.from(`rebuilt:${JSON.stringify(json)}`, "utf-8"),
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/services/swf/nitro-builder", () => ({
|
||||
parseNitroBundle: vi.fn(() => ({ json: { xdim: 1, ydim: 1 } })),
|
||||
parseNitroBundle: vi.fn(() => ({
|
||||
json: { xdim: 1, ydim: 1 },
|
||||
texture: Buffer.from("texture-bytes"),
|
||||
textureFileName: "chair.png",
|
||||
})),
|
||||
createNitroBundle: nitroBuilderMock.createNitroBundle,
|
||||
}));
|
||||
|
||||
import {
|
||||
@@ -135,11 +146,19 @@ describe("uploadSingleFurni live asset mirrors", () => {
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
// The bundle is re-written through the builder so `meta.image` can never
|
||||
// disagree with the texture member, while the member keeps the name it
|
||||
// arrived with (colour variants share a library name).
|
||||
expect(nitroBuilderMock.createNitroBundle).toHaveBeenCalledWith(
|
||||
{ xdim: 1, ydim: 1 },
|
||||
Buffer.from("texture-bytes"),
|
||||
"chair",
|
||||
);
|
||||
await expect(
|
||||
fs.readFile(
|
||||
getRuntimePath(assetTargets.mirrorDirs[0].nitroDir, "chair.nitro"),
|
||||
),
|
||||
).resolves.toEqual(nitroBuffer);
|
||||
).resolves.toEqual(Buffer.from('rebuilt:{"xdim":1,"ydim":1}', "utf-8"));
|
||||
await expect(
|
||||
fs.readFile(
|
||||
getRuntimePath(assetTargets.mirrorDirs[0].iconDir, "chair_icon.png"),
|
||||
|
||||
Reference in new issue
Block a user