From 21c242c9a446ff3db33cfe693f6952e4466a5485 Mon Sep 17 00:00:00 2001 From: cnc Date: Wed, 3 Jun 2026 21:32:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E8=80=83=E6=89=80=E6=9C=89=E5=88=86?= =?UTF-8?q?=E7=BB=84=EF=BC=8C=E5=AE=8C=E6=88=90=E5=B0=BD=E9=87=8F=E5=A4=9A?= =?UTF-8?q?=E7=9A=84=E5=86=85=E5=AE=B9=E3=80=82=E7=A6=81=E6=AD=A2=E9=A1=BA?= =?UTF-8?q?=E6=89=8B=E6=89=A9=E5=8A=9F=E8=83=BD=20smoke?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:按 LinuxCNC rs274ngc_pre.cc save_parameters()/restore_parameters() 的参数文件流程,收紧 OPFS 参数持久化后 WASM 根目录 scratch 文件清理;未扩展临时 smoke 行为。 --- web/src/wasm-core.js | 1 + web/test-browser-wasm-smoke-opfs-parameter-sections.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/web/src/wasm-core.js b/web/src/wasm-core.js index 513a692..14e0526 100644 --- a/web/src/wasm-core.js +++ b/web/src/wasm-core.js @@ -533,6 +533,7 @@ function installOpfsWorkspace(module, options) { } else { await removeOpfsFileEntry(workspacePath, `${path}.bak`); } + cleanupLinuxCncParameterFiles(module); return data; }, async removeFile(path) { diff --git a/web/test-browser-wasm-smoke-opfs-parameter-sections.js b/web/test-browser-wasm-smoke-opfs-parameter-sections.js index 83fb561..0d22989 100644 --- a/web/test-browser-wasm-smoke-opfs-parameter-sections.js +++ b/web/test-browser-wasm-smoke-opfs-parameter-sections.js @@ -16,13 +16,13 @@ export async function runBrowserOpfsParameterSections(context, simulator) { withSmokeSimulator, } = context; const backend = { backend: "linuxcnc-rs274" }; - const parseWithParameters = (program, path) => - simulator.parseWithParameterFile(program, path, "linuxcnc", backend); + const parseWithParameters = (program, path) => simulator.parseWithParameterFile(program, path, "linuxcnc", backend); await runSection("opfs parameter save", async () => { await simulator.parseWithParameterFile("G21 G90\nG0 X1\nG28.1\nM30\n", "parameters/rs274ngc.var", "linuxcnc", backend); const opfsParameterFile = await readOpfsText(simulator, "parameters/rs274ngc.var"); expectIncludes(opfsParameterFile, "5161\t1.000000", "LinuxCNC parameter file was not persisted into OPFS"); + expectWasmFilesMissing(simulator.fs.module.FS, ["rs274ngc.var", "rs274ngc.var.new", "rs274ngc.var.bak"], (parameterPath) => `LinuxCNC parameter scratch file remained outside OPFS after save: ${parameterPath}`); }); await runSection("opfs parameter restore in new instance", async () => { @@ -84,6 +84,7 @@ export async function runBrowserOpfsParameterSections(context, simulator) { const opfsParameterBackup = await readOpfsText(simulator, "parameters/backup-bridge.var.bak"); expectIncludes(opfsParameterBackup, "5161\t1.000000", "LinuxCNC parameter backup file was not bridged into OPFS"); + expectWasmFilesMissing(simulator.fs.module.FS, ["rs274ngc.var", "rs274ngc.var.new", "rs274ngc.var.bak"], (parameterPath) => `LinuxCNC parameter scratch file remained outside OPFS after backup bridge: ${parameterPath}`); }); await runSection("opfs parameter backup after existing save", async () => {