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
@@ -1,4 +1,4 @@
|
||||
import { access, readFile, stat } from 'node:fs/promises';
|
||||
import { access, readFile, realpath, stat } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { executableVersion, GAME_FILES, isInSteamLibrary, recordedGameVersions } from '@wto/patcher';
|
||||
import { AppError } from '@shared/errors.ts';
|
||||
@@ -11,18 +11,20 @@ import { resourcePaths } from '../resources/resource-paths.ts';
|
||||
*/
|
||||
export async function inspectGameFolder(path: string): Promise<GameFolderInspection> {
|
||||
await requireFolder(path);
|
||||
const resolved = await realpath(path);
|
||||
const required = Object.values(GAME_FILES);
|
||||
const missingFiles: string[] = [];
|
||||
for (const file of required) {
|
||||
if (!(await exists(join(path, file)))) missingFiles.push(file);
|
||||
if (!(await exists(join(resolved, file)))) missingFiles.push(file);
|
||||
}
|
||||
const resources = resourcePaths();
|
||||
return {
|
||||
path,
|
||||
resolvedPath: resolved,
|
||||
missingFiles,
|
||||
version: missingFiles.includes(GAME_FILES.executable) ? null : await readVersion(join(path, GAME_FILES.executable)),
|
||||
version: missingFiles.includes(GAME_FILES.executable) ? null : await readVersion(join(resolved, GAME_FILES.executable)),
|
||||
verifiedVersions: recordedGameVersions(resources.patches),
|
||||
inSteamLibrary: isInSteamLibrary(path),
|
||||
inSteamLibrary: isInSteamLibrary(path) || isInSteamLibrary(resolved),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import { readdir, realpath, stat, statfs } from 'node:fs/promises';
|
||||
import { readdir, stat, statfs } from 'node:fs/promises';
|
||||
import { dirname, relative, resolve, isAbsolute } from 'node:path';
|
||||
import { isInSteamLibrary } from '@wto/patcher';
|
||||
import type { TargetFolderInspection } from '@shared/schemas/install.ts';
|
||||
import { canonicalCopyPath } from '../install/install-record.ts';
|
||||
|
||||
/**
|
||||
* Look at the folder the player chose for the game copy (install by copying): it must be new or
|
||||
* empty, must not overlap the stock installation, and the drive must have room. Only reads.
|
||||
*/
|
||||
export async function inspectTargetFolder(path: string, stockPath: string): Promise<TargetFolderInspection> {
|
||||
const target = await canonical(path);
|
||||
const stock = await canonical(stockPath);
|
||||
const [target, stock] = await Promise.all([canonicalCopyPath(path), canonicalCopyPath(stockPath)]);
|
||||
return {
|
||||
path,
|
||||
resolvedPath: target,
|
||||
problem: await targetProblem(target, stock),
|
||||
inSteamLibrary: isInSteamLibrary(target),
|
||||
inSteamLibrary: isInSteamLibrary(path) || isInSteamLibrary(target),
|
||||
freeBytes: await freeBytes(target),
|
||||
sameDriveAsStock: await sameVolume(target, stock),
|
||||
};
|
||||
@@ -65,15 +66,3 @@ export async function freeBytes(path: string): Promise<number | null> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The real path of the nearest existing part, with the rest appended as given. */
|
||||
async function canonical(path: string): Promise<string> {
|
||||
const absolute = resolve(path);
|
||||
try {
|
||||
return await realpath(absolute);
|
||||
} catch {
|
||||
const parent = dirname(absolute);
|
||||
if (parent === absolute) return absolute;
|
||||
return resolve(await canonical(parent), relative(parent, absolute));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user