fix(copies): honor confirmed Steam locations
Bind confirmation to the selected copy and data paths throughout installation, launch, and maintenance. Validate redirected runtime data paths and recheck original files before refreshing an in-place backup. Verified by type checking and build. The acceptance checklist covers directory links and Steam confirmation.
This commit is contained in:
1 parent
84158f719d
commit
5a78b1fdf8
28 files changed
+813
-459
No files matched your search
@@ -5,6 +5,7 @@ export interface BuildRequest {
|
||||
readonly stockPath: string;
|
||||
readonly copyPath: string;
|
||||
readonly dataPath: string;
|
||||
readonly steamLibraryConfirmed: boolean;
|
||||
readonly port: number;
|
||||
readonly patches: string;
|
||||
readonly networkHookLibrary: string;
|
||||
|
||||
@@ -5,7 +5,16 @@ import { assertWritableCopy, buildGameCopy, copyPlayerDecalCache, playerDecalCac
|
||||
import { multiVehiclePackIds } from '@wto/server';
|
||||
import type { BuildCommand, BuildReply, BuildRequest } from './build-protocol.ts';
|
||||
|
||||
let prepared: { readonly copyPath: string; readonly files: readonly GameCopyFile[]; readonly decalCache: string | undefined } | null = null;
|
||||
let prepared: {
|
||||
readonly request: BuildRequest;
|
||||
readonly files: readonly GameCopyFile[];
|
||||
readonly decalCache: string | undefined;
|
||||
} | null = null;
|
||||
|
||||
function checkBuildLocation({ stockPath, copyPath, steamLibraryConfirmed }: BuildRequest): void {
|
||||
if (relative(copyPath, realpathSync(copyPath)) !== '') throw new Error('The copy path changed during the build.');
|
||||
assertWritableCopy(stockPath, copyPath, { steamLibraryConfirmed });
|
||||
}
|
||||
|
||||
function send(reply: BuildReply): void {
|
||||
process.parentPort.postMessage(reply);
|
||||
@@ -23,7 +32,7 @@ function importedDecals(path: string | undefined): string | undefined {
|
||||
}
|
||||
|
||||
function build(request: BuildRequest): void {
|
||||
assertWritableCopy(request.stockPath, request.copyPath);
|
||||
checkBuildLocation(request);
|
||||
const decalCache = importedDecals(request.decalCache);
|
||||
const result = buildGameCopy({
|
||||
stock: readStockGameFiles(request.stockPath),
|
||||
@@ -40,7 +49,7 @@ function build(request: BuildRequest): void {
|
||||
send({ kind: 'failed', error: 'launch_build_unavailable' });
|
||||
return;
|
||||
}
|
||||
prepared = { copyPath: request.copyPath, files: result.files, decalCache };
|
||||
prepared = { request, files: result.files, decalCache };
|
||||
send({ kind: 'prepared', total: prepared.files.length });
|
||||
}
|
||||
|
||||
@@ -52,8 +61,10 @@ process.parentPort.on('message', (event: MessageEvent) => {
|
||||
return;
|
||||
}
|
||||
if (!prepared) throw new Error('No build is ready to write.');
|
||||
const { copyPath, files, decalCache } = prepared;
|
||||
const { request, files, decalCache } = prepared;
|
||||
prepared = null;
|
||||
checkBuildLocation(request);
|
||||
const { copyPath } = request;
|
||||
if (decalCache) copyPlayerDecalCache(decalCache, copyPath);
|
||||
for (const [index, file] of files.entries()) {
|
||||
writeGameCopy(copyPath, [file]);
|
||||
|
||||
Reference in new issue
Block a user