fix(desktop): retry Windows settings file replacement

This commit is contained in:
Bohdan Triapitsyn
2026-08-22 14:44:03 +03:00
parent 049ff52427
commit 09f75b75e1
4 changed files with 114 additions and 2 deletions
+3 -1
View File
@@ -5,6 +5,8 @@ import os from 'node:os';
import path from 'node:path';
import { spawn } from 'node:child_process';
import { replaceFileWithRetry } from './windows-file-replace.mjs';
const LOCAL_HOST_ID = 'local';
const DEFAULT_CONNECTION_TIMEOUT_SEC = 60;
const DEFAULT_LOCAL_BIND_HOST = '127.0.0.1';
@@ -81,7 +83,7 @@ const writeJsonRoot = async (settingsFilePath, root) => {
const tmp = `${settingsFilePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
try {
await fsp.writeFile(tmp, JSON.stringify(root, null, 2));
await fsp.rename(tmp, settingsFilePath);
await replaceFileWithRetry(tmp, settingsFilePath);
} catch (error) {
await fsp.rm(tmp, { force: true }).catch(() => {});
throw error;