参考所有分组,完成尽量多的内容。禁止顺手扩功能 smoke
结论:按 align-linuxcnc 约束收窄 OPFS removeFile 和 LinuxCNC 参数 .new/.bak 清理为文件专用语义,避免把同名目录递归删除。依据 ../linuxcnc/src/emc/rs274ngc/rs274ngc_pre.cc save_parameters() 的 fopen(filename.new)、unlink(filename.bak)、link、rename 行为。 验证:./test-native.sh 通过;./test-linuxcnc-source-link.sh 通过。
This commit is contained in:
@@ -171,4 +171,20 @@ export async function runBrowserOpfsDirectorySections(context, simulator) {
|
||||
"OPFS removeDirectory did not remove the WASM mirror",
|
||||
);
|
||||
});
|
||||
|
||||
await runSection("opfs file removal preserves directories", async () => {
|
||||
await simulator.fs.opfs.writeFile("parameters/remove-file-keeps-directory.var.new/stale.ngc", "G21 G90\n");
|
||||
const staleDirectoryPath = simulator.fs.opfs.resolvePath("parameters/remove-file-keeps-directory.var.new");
|
||||
await simulator.fs.opfs.readDirectory("parameters/remove-file-keeps-directory.var.new");
|
||||
await simulator.fs.opfs.removeFile("parameters/remove-file-keeps-directory.var.new");
|
||||
const staleDirectoryStat = await simulator.fs.opfs.stat("parameters/remove-file-keeps-directory.var.new");
|
||||
if (staleDirectoryStat.kind !== "directory" || staleDirectoryStat.size !== null) {
|
||||
throw new Error("OPFS removeFile removed a directory instead of preserving file-only semantics");
|
||||
}
|
||||
const staleDirectoryMode = simulator.fs.module.FS.stat(staleDirectoryPath).mode;
|
||||
if (!simulator.fs.module.FS.isDir(staleDirectoryMode)) {
|
||||
throw new Error("OPFS removeFile removed a WASM mirror directory instead of preserving file-only semantics");
|
||||
}
|
||||
await simulator.fs.opfs.removeDirectory("parameters/remove-file-keeps-directory.var.new");
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user