feat(catalog): generate derived scale 32 with preview and backup restore
This commit is contained in:
1 parent
08b0b5021e
commit
cd75361b9f
9 files changed
+749
-11
No files matched your search
@@ -105,15 +105,23 @@ export const PUT = withAdmin(
|
||||
if (!existsSync(/*turbopackIgnore: true*/ nitroPath))
|
||||
return apiError("Nitro file not found", 404);
|
||||
|
||||
// 1. Read existing .nitro to extract PNG
|
||||
const existingBuffer = await fs.readFile(
|
||||
/*turbopackIgnore: true*/ nitroPath,
|
||||
);
|
||||
const { png } = parseNitroBundle(existingBuffer);
|
||||
|
||||
// 2. Rebuild .nitro with updated JSON + same PNG
|
||||
const newBundle = createNitroBundle(metadata, png, base);
|
||||
await fs.writeFile(nitroPath, newBundle);
|
||||
const saved = await withFurniDataLock(async () => {
|
||||
const existingBuffer = await fs.readFile(nitroPath);
|
||||
const { png, json: currentMetadata } = parseNitroBundle(existingBuffer);
|
||||
if (
|
||||
JSON.stringify(currentMetadata.catalogStudio) !==
|
||||
JSON.stringify(metadata.catalogStudio)
|
||||
)
|
||||
return false;
|
||||
const newBundle = createNitroBundle(metadata, png, base);
|
||||
await fs.writeFile(nitroPath, newBundle);
|
||||
return true;
|
||||
});
|
||||
if (!saved)
|
||||
return apiError(
|
||||
"The bundle changed. Reopen the editor before saving.",
|
||||
409,
|
||||
);
|
||||
|
||||
// 3. Extract dimensions from metadata
|
||||
const dims = metadata.logic?.model?.dimensions || { x: 1, y: 1, z: 0 };
|
||||
|
||||
Reference in new issue
Block a user