验证 OPFS rename 持久清理

提示词:快速推进,避免纯 source-map-only,不自动推送。

结论:基于 LinuxCNC rs274ngc_pre.cc save_parameters() 的 filename + .new rename 语义,补强浏览器 OPFS moveFile 在新 WASM 实例中持久删除源文件并恢复目标 mirror 的覆盖;./test-native.sh 和 ./test-linuxcnc-source-link.sh 通过。
This commit is contained in:
cnc
2026-06-06 06:31:30 +08:00
parent 6efb77b8e4
commit 586c28656d
3 changed files with 24 additions and 0 deletions

View File

@@ -88,6 +88,25 @@ export async function runBrowserOpfsMirrorSections(context, simulator) {
() => simulator.fs.module.FS.stat(movedTemporaryWasmPath),
"OPFS moveFile left the WASM mirror source behind",
);
await withSmokeSimulator(async (restoredMoveSimulator) => {
const restoredMovedParameterFile = await readOpfsText(restoredMoveSimulator, "parameters/move-main.var");
expectText(restoredMovedParameterFile, "5161\t2.000000\n",
"OPFS moveFile destination was not persisted for a new WASM instance");
if (await restoredMoveSimulator.fs.opfs.exists("parameters/move-main.var.new")) {
throw new Error("OPFS moveFile source was still persisted for a new WASM instance");
}
const restoredMovedParameterWasmPath = restoredMoveSimulator.fs.opfs.resolvePath("parameters/move-main.var");
const restoredMovedParameterWasm = new TextDecoder().decode(
restoredMoveSimulator.fs.module.FS.readFile(restoredMovedParameterWasmPath),
);
expectText(restoredMovedParameterWasm, "5161\t2.000000\n",
"OPFS moveFile destination was not mirrored for a new WASM instance");
const restoredMovedTemporaryWasmPath = restoredMoveSimulator.fs.opfs.resolvePath("parameters/move-main.var.new");
expectMissingWasmPath(
() => restoredMoveSimulator.fs.module.FS.stat(restoredMovedTemporaryWasmPath),
"OPFS moveFile source was mirrored for a new WASM instance",
);
});
await simulator.fs.opfs.writeFile("parameters/mirror-conflict-source.var", "5161\t3.000000\n");
const copyConflictPath = simulator.fs.opfs.resolvePath("parameters/mirror-conflict-copy.var");