Complete XYZAC LinuxCNC WASM parity and smooth 3D preview
This commit is contained in:
@@ -38,7 +38,7 @@ export async function runOpfsProbe({ storage, projectId = "s6-05-opfs", mode = "
|
||||
const probe = opfsCapability({ navigator: { storage } });
|
||||
if (probe.status !== "verified") return { schema: OPFS_RUNTIME_SCHEMA, ...probe, project_id: projectId };
|
||||
if (!validProjectId(projectId)) return { schema: OPFS_RUNTIME_SCHEMA, status: "blocked", code: "opfs_project_id_invalid" };
|
||||
if (!["round_trip", "write", "read"].includes(mode)) return { schema: OPFS_RUNTIME_SCHEMA, status: "blocked", code: "opfs_mode_invalid", project_id: projectId };
|
||||
if (!["round_trip", "write", "read", "corrupt"].includes(mode)) return { schema: OPFS_RUNTIME_SCHEMA, status: "blocked", code: "opfs_mode_invalid", project_id: projectId };
|
||||
let access = null;
|
||||
try {
|
||||
const rootResult = await rootHandle(storage);
|
||||
@@ -64,6 +64,18 @@ export async function runOpfsProbe({ storage, projectId = "s6-05-opfs", mode = "
|
||||
access.close();
|
||||
access = null;
|
||||
if (mode === "write") return { schema: OPFS_RUNTIME_SCHEMA, status: "verified", mode, project_id: projectId, bytes: encoded.byteLength, commit_seq: record.commit_seq, content_hash: record.content_hash, cleanup: false };
|
||||
if (mode === "corrupt") {
|
||||
const corrupt = await file.createSyncAccessHandle();
|
||||
corrupt.write(TEXT_ENCODER.encode("{corrupt"), { at: 0 });
|
||||
corrupt.flush();
|
||||
corrupt.close();
|
||||
let damaged = null;
|
||||
try { damaged = JSON.parse(await (await file.getFile()).text()); } catch { damaged = null; }
|
||||
if (cleanup) { await project.removeEntry(FILE_NAME); await directory.removeEntry(projectId); }
|
||||
return !validateCommittedRecord(damaged, projectId)
|
||||
? { schema: OPFS_RUNTIME_SCHEMA, status: "verified", mode, project_id: projectId, corruption_detected: true, cleanup }
|
||||
: { schema: OPFS_RUNTIME_SCHEMA, status: "blocked", code: "opfs_corruption_undetected", project_id: projectId };
|
||||
}
|
||||
const persisted = JSON.parse(await (await file.getFile()).text());
|
||||
const valid = written === encoded.byteLength && size === encoded.byteLength && JSON.stringify(persisted) === JSON.stringify(record);
|
||||
if (cleanup) { await project.removeEntry(FILE_NAME); await directory.removeEntry(projectId); }
|
||||
|
||||
Reference in New Issue
Block a user