From 586c28656d02420bb2e1091400597f6054f2a446 Mon Sep 17 00:00:00 2001 From: cnc Date: Sat, 6 Jun 2026 06:31:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81=20OPFS=20rename=20=E6=8C=81?= =?UTF-8?q?=E4=B9=85=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 提示词:快速推进,避免纯 source-map-only,不自动推送。 结论:基于 LinuxCNC rs274ngc_pre.cc save_parameters() 的 filename + .new rename 语义,补强浏览器 OPFS moveFile 在新 WASM 实例中持久删除源文件并恢复目标 mirror 的覆盖;./test-native.sh 和 ./test-linuxcnc-source-link.sh 通过。 --- check-linuxcnc-opfs-source-map.sh | 2 ++ test-web-wasm-browser-smoke.sh | 3 +++ ...browser-wasm-smoke-opfs-mirror-sections.js | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/check-linuxcnc-opfs-source-map.sh b/check-linuxcnc-opfs-source-map.sh index e83e199..a6a7bca 100755 --- a/check-linuxcnc-opfs-source-map.sh +++ b/check-linuxcnc-opfs-source-map.sh @@ -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 diff --git a/test-web-wasm-browser-smoke.sh b/test-web-wasm-browser-smoke.sh index 69073a3..46024d6 100755 --- a/test-web-wasm-browser-smoke.sh +++ b/test-web-wasm-browser-smoke.sh @@ -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"', ), diff --git a/web/test-browser-wasm-smoke-opfs-mirror-sections.js b/web/test-browser-wasm-smoke-opfs-mirror-sections.js index e8b91b3..884313b 100644 --- a/web/test-browser-wasm-smoke-opfs-mirror-sections.js +++ b/web/test-browser-wasm-smoke-opfs-mirror-sections.js @@ -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");