feat(launcher): add client origin marker and stock restore removal flow

Write a self-describing wtoffline/client.json origin marker (copy, hardlink, or in-place) on install, space-saving compaction, and hardlink-detaching updates, and read it with lightweight hardlink nlink sampling when inspecting existing folders. Allow deleting existing folders only when backed by a valid copy/hardlink marker outside Steam and disjoint from all registered source paths, and add an atomic restore-stock-and-remove option that restores the four stock core files and removes only wto_ws.{dll,cfg,log} and wtoffline/.
This commit is contained in:
N0VAN0M4LY committed 2026-12-04 20:38:08 +08:00
1 parent 29736870ac
commit 49264b0326
15 files changed
+626 -207

No files matched your search

@@ -1,6 +1,31 @@
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
import { dirname, join } from 'node:path';
import { AppError } from '@shared/errors.ts';
import type { DataFolderProblem } from '@shared/schemas/install.ts';
import { copyPathContains } from './install-record.ts';
import { STOCK_BACKUP_FOLDER } from './stock-backup.ts';
/**
* Validate where the offline data folder sits relative to the client and stock folders.
* A subfolder inside the client (outside wtoffline/) is allowed, while setting dataPath to the
* client folder itself or an ancestor of it would mix game files into the data root.
*/
export function dataFolderProblem(
dataPath: string,
copyPath: string | null,
sourcePath: string | null,
externalStockPath: string | null,
): DataFolderProblem | null {
if (copyPath && (copyPathContains(dataPath, copyPath) ||
copyPathContains(join(copyPath, dirname(STOCK_BACKUP_FOLDER)), dataPath))) {
return 'overlaps_client';
}
if ((sourcePath && copyPathContains(sourcePath, dataPath)) ||
(externalStockPath && copyPathContains(externalStockPath, dataPath))) {
return 'overlaps_stock';
}
return null;
}
/** A data tree must keep the server's saves, logs and caches inside the selected folder. */
export async function requireUnredirectedData(root: string): Promise<void> {