feat(launcher): support registering existing offline clients without copying
This commit is contained in:
1 parent
7cb1011f0d
commit
cae69a6446
11 files changed
+107
-30
No files matched your search
@@ -3,11 +3,12 @@ import { join } from 'node:path';
|
||||
import { executableVersion, GAME_FILES, isInSteamLibrary, recordedGameVersions } from '@wto/patcher';
|
||||
import { AppError } from '@shared/errors.ts';
|
||||
import type { GameFolderInspection } from '@shared/schemas/install.ts';
|
||||
import { STOCK_BACKUP_FOLDER } from '../install/stock-backup.ts';
|
||||
import { resourcePaths } from '../resources/resource-paths.ts';
|
||||
|
||||
/**
|
||||
* Look at a folder the player chose as their War Thunder installation: is it one, which version,
|
||||
* and is it a Steam library. Only reads.
|
||||
* whether it already has an offline stock backup, and whether it is inside a Steam library. Only reads.
|
||||
*/
|
||||
export async function inspectGameFolder(path: string): Promise<GameFolderInspection> {
|
||||
await requireFolder(path);
|
||||
@@ -17,14 +18,26 @@ export async function inspectGameFolder(path: string): Promise<GameFolderInspect
|
||||
for (const file of required) {
|
||||
if (!(await exists(join(resolved, file)))) missingFiles.push(file);
|
||||
}
|
||||
const stockRoot = join(resolved, STOCK_BACKUP_FOLDER);
|
||||
let hasOfflineBackup = true;
|
||||
for (const file of required) {
|
||||
if (!(await exists(join(stockRoot, file)))) {
|
||||
hasOfflineBackup = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const resources = resourcePaths();
|
||||
const executablePath = hasOfflineBackup
|
||||
? join(stockRoot, GAME_FILES.executable)
|
||||
: join(resolved, GAME_FILES.executable);
|
||||
return {
|
||||
path,
|
||||
resolvedPath: resolved,
|
||||
missingFiles,
|
||||
version: missingFiles.includes(GAME_FILES.executable) ? null : await readVersion(join(resolved, GAME_FILES.executable)),
|
||||
version: !hasOfflineBackup && missingFiles.includes(GAME_FILES.executable) ? null : await readVersion(executablePath),
|
||||
verifiedVersions: recordedGameVersions(resources.patches),
|
||||
inSteamLibrary: isInSteamLibrary(path) || isInSteamLibrary(resolved),
|
||||
hasOfflineBackup,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ async function install(request: InstallRequest, signal: AbortSignal, report: (pr
|
||||
: undefined;
|
||||
|
||||
report({ phase: 'backing-up', doneBytes: 0, totalBytes: 0, doneFiles: 0, totalFiles: 0 });
|
||||
const stockBackup = request.method === 'in-place' && stock.refresh
|
||||
const stockBackup = (request.method === 'in-place' || request.method === 'existing') && stock.refresh
|
||||
? await refreshStockBackup(copyPath)
|
||||
: await backUpStockFiles(copyPath);
|
||||
|
||||
|
||||
Reference in new issue
Block a user