验证 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

@@ -107,6 +107,8 @@ grep -F 'runSection("opfs directory persist and load"' \
web/test-browser-wasm-smoke-opfs-directory-sections.js >/dev/null
grep -F 'runSection("opfs metadata queries avoid wasm mirror pollution"' \
web/test-browser-wasm-smoke-opfs-directory-sections.js >/dev/null
grep -F 'runSection("opfs copy and move mirror files"' \
web/test-browser-wasm-smoke-opfs-mirror-sections.js >/dev/null
grep -F 'runSection("browser opfs policy"' \
web/test-browser-wasm-smoke-opfs-policy-sections.js >/dev/null
grep -F 'runSection("opfs parameter restore in new instance"' test-web-wasm-browser-smoke.sh >/dev/null

View File

@@ -179,6 +179,9 @@ required_browser_sections = {
'runSection("opfs directory persist and load"',
'runSection("opfs metadata queries avoid wasm mirror pollution"',
),
"web/test-browser-wasm-smoke-opfs-mirror-sections.js": (
'runSection("opfs copy and move mirror files"',
),
"web/test-browser-wasm-smoke-opfs-policy-sections.js": (
'runSection("browser opfs policy"',
),

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");