fix(saves): keep imported presets intact, cap crews to preset units and drop used-unit scan
This commit is contained in:
1 parent
388dc9d9d7
commit
e6e75d92c6
10 files changed
+109
-114
No files matched your search
@@ -190,11 +190,16 @@ function onlineSavesRoot(): string {
|
||||
return join(app.getPath('documents'), 'My Games', 'WarThunder', 'Saves');
|
||||
}
|
||||
|
||||
async function offlineClientCacheFolder(userId: string): Promise<string | undefined> {
|
||||
if (!/^\d+$/.test(userId)) return undefined;
|
||||
async function offlineClientCacheFolders(userId: string): Promise<string[]> {
|
||||
if (!/^\d+$/.test(userId)) return [];
|
||||
const root = await canonicalCopyPath(join(app.getPath('documents'), 'My Games', 'WTOffline', 'Saves'));
|
||||
const target = await canonicalCopyPath(join(root, userId, 'production'));
|
||||
return copyPathContains(root, target) ? target : undefined;
|
||||
const candidates = [join(root, userId, 'production'), join(root, 'last', 'production')];
|
||||
const folders: string[] = [];
|
||||
for (const candidate of candidates) {
|
||||
const resolved = await canonicalCopyPath(candidate);
|
||||
if (copyPathContains(root, resolved)) folders.push(resolved);
|
||||
}
|
||||
return folders;
|
||||
}
|
||||
|
||||
/** Read-only discovery of local online client settings under Documents/My Games/WarThunder/Saves. */
|
||||
@@ -276,12 +281,12 @@ export async function pickOfficialBackups(window: BrowserWindow | null): Promise
|
||||
}
|
||||
|
||||
export async function previewSelectedBackups(
|
||||
copyId: string, userId: string, paths: readonly string[], includeUsedVehicles: boolean,
|
||||
copyId: string, userId: string, paths: readonly string[],
|
||||
): Promise<OfficialPreview> {
|
||||
const copy = await requireCopy(copyId);
|
||||
await getSaveDetails(copyId, userId);
|
||||
const selected = await verifyBackupLocations(copy, paths);
|
||||
return await run({ operation: 'previewOfficial', ...location(copy), paths: selected, includeUsedVehicles }) as OfficialPreview;
|
||||
return await run({ operation: 'previewOfficial', ...location(copy), paths: selected }) as OfficialPreview;
|
||||
}
|
||||
|
||||
export async function importSelectedBackups(
|
||||
@@ -291,7 +296,7 @@ export async function importSelectedBackups(
|
||||
const copy = await requireCopy(copyId);
|
||||
await getSaveDetails(copyId, userId);
|
||||
const selected = await verifyBackupLocations(copy, paths);
|
||||
const cacheFolder = await offlineClientCacheFolder(userId);
|
||||
const cacheFolders = await offlineClientCacheFolders(userId);
|
||||
const before = await captureSave(copy, userId);
|
||||
await saveBackup(copy, userId, 'import');
|
||||
try {
|
||||
@@ -301,7 +306,7 @@ export async function importSelectedBackups(
|
||||
userId,
|
||||
paths: selected,
|
||||
options,
|
||||
...(cacheFolder ? { offlineClientCacheFolder: cacheFolder } : {}),
|
||||
...(cacheFolders.length > 0 ? { offlineClientCacheFolders: cacheFolders } : {}),
|
||||
}) as OfficialPreview;
|
||||
} catch (error) {
|
||||
await restoreDirectory(copy, userId, before);
|
||||
|
||||
Reference in new issue
Block a user