按源保护 OPFS 参数备份失败边界

This commit is contained in:
cnc
2026-06-06 06:06:03 +08:00
parent e320d6d420
commit 8544872198
2 changed files with 33 additions and 1 deletions

View File

@@ -529,7 +529,12 @@ function installOpfsWorkspace(module, options) {
const backupPath = `${LINUXCNC_DEFAULT_PARAMETER_FILE}.bak`;
const backupData = readFirstExistingWasmFile(module, [backupPath, `/${backupPath}`]);
if (backupData !== null) {
await writeOpfsFile(workspacePath, `${path}.bak`, backupData);
try {
await writeOpfsFile(workspacePath, `${path}.bak`, backupData);
} catch (_backupError) {
// LinuxCNC reports link(filename, filename + ".bak") failures
// with perror() and still renames filename + ".new" over filename.
}
} else {
await removeOpfsFileEntry(workspacePath, `${path}.bak`);
}