feat(copies): add verified space-saving copies

Offer same-volume hard links for sampled 2.61.0.43 resources after checking their content and keeping mutable files independent. Support converting existing copies and detach registered links during version updates.
This commit is contained in:
N0VAN0M4LY committed 2026-11-30 05:51:22 +08:00
1 parent 0881d62766
commit 2a97b0d46c
22 files changed
+3118 -111

No files matched your search

+3
View File
@@ -68,6 +68,9 @@ export const APP_ERROR_CODES = [
'patch_check_failed',
/** Copying the game failed; what was copied has been removed. */
'copy_failed',
'hardlink_unavailable',
'hardlink_no_match',
'hardlink_file_changed',
/** The player stopped the installation; what was copied has been removed. */
'install_cancelled',
/** An installation is already running. */
+1 -1
View File
@@ -79,7 +79,7 @@ export const ipcContract = {
output: TargetFolderInspectionSchema,
},
'install:measureFolder': {
input: z.object({ path: z.string().min(1) }),
input: z.object({ path: z.string().min(1), version: z.string().nullable().optional() }),
output: FolderSizeSchema,
},
'install:checkPatches': {
+5 -1
View File
@@ -38,6 +38,7 @@ export type TargetFolderInspection = z.output<typeof TargetFolderInspectionSchem
export const FolderSizeSchema = z.object({
bytes: z.number(),
files: z.number(),
linkableBytes: z.number().nonnegative().optional(),
});
export type FolderSize = z.output<typeof FolderSizeSchema>;
@@ -94,6 +95,7 @@ const InstallChoicesSchema = z.object({
export const InstallRequestSchema = z.discriminatedUnion('method', [
InstallChoicesSchema.extend({
method: z.literal('copy'),
useHardLinks: z.boolean().optional(),
/** The War Thunder installation to copy; only read. */
sourcePath: z.string().min(1),
/** A new or empty folder for the game copy. */
@@ -107,7 +109,7 @@ export const InstallRequestSchema = z.discriminatedUnion('method', [
]);
export type InstallRequest = z.output<typeof InstallRequestSchema>;
export const INSTALL_PHASES = ['checking', 'measuring', 'copying', 'backing-up', 'recording'] as const;
export const INSTALL_PHASES = ['checking', 'measuring', 'verifying', 'copying', 'backing-up', 'recording'] as const;
export const InstallProgressSchema = z.object({
phase: z.enum(INSTALL_PHASES),
@@ -137,6 +139,8 @@ export const InstallRecordSchema = z.object({
currentSaveId: z.string().regex(/^\d+$/).optional(),
/** Relative paths read from the installation source during the last copy or update. */
sourceFiles: z.array(z.string().min(1)).optional(),
/** Relative resource paths linked to the source and detached on a version update. */
hardlinkedFiles: z.array(z.string().min(1)).optional(),
});
export type InstallRecord = z.output<typeof InstallRecordSchema>;
@@ -1,7 +1,7 @@
import { z } from 'zod';
import { CopyIdSchema } from './install.ts';
export const MaintenanceOperationSchema = z.enum(['check', 'repair', 'update', 'delete']);
export const MaintenanceOperationSchema = z.enum(['check', 'repair', 'update', 'compact', 'delete']);
export const MaintenanceRequestSchema = z.object({
id: CopyIdSchema,
operation: MaintenanceOperationSchema,
@@ -10,6 +10,7 @@ export const MaintenanceRequestSchema = z.object({
export const MaintenanceInfoSchema = z.object({
sourceVersion: z.string().nullable(),
updateAvailable: z.boolean(),
spaceSavingAvailable: z.boolean(),
});
export const MaintenanceProgressSchema = z.object({
id: CopyIdSchema,