Electron patches node:fs to treat any .asar file on disk as a virtual archive directory. When a player's War Thunder source directory contains an .asar file (for example from a leftover portable launcher folder previously unpacked inside the game folder), createReadStream fails with ENOENT and aborts full-copy installation. Changes: - Add rawFs() helper using Electron's original-fs (with node:fs fallback) and use it across copy-game.ts and change-copy-files.ts for directory scans, streaming copies, timestamp preservation, rollback and cleanup. - Preserve the first non-cancellation worker error in copyPlannedFiles so sibling AbortError rejections do not mask the real filesystem or hardlink error. - Skip nested subfolders containing WTOffline Launcher.exe during planCopy, and reject copy installation upfront with launcher_inside_source when the packaged launcher itself runs from inside the selected source game directory (with en and zh-CN messages). Verification: - Root and launcher typecheck passed. - Launcher electron-vite build passed. - en.json and zh-CN.json key parity check passed (720 keys). - Verified in Electron that patched node:fs reproduces ENOENT on default_app.asar while original-fs copies and cleans it up cleanly. - Packaged installer end-to-end verification pending.
24 lines
716 B
TypeScript
24 lines
716 B
TypeScript
import * as nodeFs from 'node:fs';
|
|
import { createRequire } from 'node:module';
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
let cached: typeof nodeFs | null = null;
|
|
|
|
/**
|
|
* Return Node's unpatched fs module inside Electron.
|
|
*
|
|
* Electron patches `node:fs` to treat any `.asar` file anywhere on disk as a virtual archive
|
|
* directory, which breaks streaming reads, stats and recursive cleanup when copying or managing
|
|
* player folders that happen to contain an `.asar` file. Falls back to `node:fs` outside Electron.
|
|
*/
|
|
export function rawFs(): typeof nodeFs {
|
|
if (cached) return cached;
|
|
try {
|
|
cached = require('original-fs') as typeof nodeFs;
|
|
} catch {
|
|
cached = nodeFs;
|
|
}
|
|
return cached;
|
|
}
|