feat(saves): add save archives and copy transfers

This commit is contained in:
N0VAN0M4LY committed 2026-11-29 15:55:23 +08:00
1 parent 073a907617
commit d0a767e692
19 files changed
+660 -25

No files matched your search

@@ -4,12 +4,14 @@ import { createServer } from 'node:net';
import { isAbsolute, join, relative } from 'node:path';
import { promisify } from 'node:util';
import { BrowserWindow, shell } from 'electron';
import { AccountStore } from '@wto/server';
import { executableVersion, GAME_FILES, isInSteamLibrary } from '@wto/patcher';
import { AppError } from '@shared/errors.ts';
import type { LaunchState } from '@shared/schemas/launch.ts';
import { getSettings } from '../config/settings-store.ts';
import { readInstallRecord } from '../install/install-record.ts';
import { resourcePaths } from '../resources/resource-paths.ts';
import { saveBackup } from '../saves/save-archive.ts';
import { buildCopy } from './build-copy.ts';
import { labStatusUrl, readInstalledLab, runLab } from './lab-handoff.ts';
@@ -123,6 +125,12 @@ async function launch(job: LaunchJob): Promise<void> {
if (!labVersion || labVersion !== stockVersion) throw new AppError('launch_lab_version');
if (games) throw new AppError('launch_game_running');
await checkPort(lab.port);
if (settings.autoSaveBackups) {
for (const { userId } of new AccountStore(dataPath).all()) {
signal.throwIfAborted();
await saveBackup({ ...record, dataPath }, userId, 'launch');
}
}
signal.throwIfAborted();
update(job, { phase: 'building', port: lab.port });
await buildCopy({