Instantane de reference de la reprise de migration (2026-09-29). Contient GI.uasset tel que trouve (copie UE4 identique a 4.27, MD5 F4550DA5DC05FC005400CDCA2FC123C9). Ajouts de ce commit : .gitattributes (aucune conversion de fin de ligne), regles .gitignore CHG-001, Tools/ (Snapshot, Restore, AssetHeaders), empreintes L0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
2.8 KiB
PowerShell
66 lines
2.8 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Remet en place l'etat sauvegarde par Snapshot.ps1 pour un lot.
|
|
|
|
.DESCRIPTION
|
|
Pour chaque ligne du manifeste :
|
|
- Existed=True : recopie le fichier sauvegarde et verifie son MD5 ;
|
|
- Existed=False : le fichier a ete cree par le lot ; il est deplace vers
|
|
<BackupRoot>\<Lot>\_retires\ (jamais supprime definitivement).
|
|
Avant d'ecraser un fichier, sa version courante est conservee dans
|
|
<BackupRoot>\<Lot>\_avant-restauration\<horodatage>\ pour pouvoir annuler
|
|
la restauration elle-meme.
|
|
|
|
.EXAMPLE
|
|
.\Tools\Restore.ps1 -Lot L1 -WhatIf
|
|
.\Tools\Restore.ps1 -Lot L1 -Only Content\BPs\GI.uasset
|
|
#>
|
|
[CmdletBinding(SupportsShouldProcess)]
|
|
param(
|
|
[Parameter(Mandatory)][string]$Lot,
|
|
[string[]]$Only,
|
|
[string]$ProjectRoot = (Split-Path $PSScriptRoot -Parent),
|
|
[string]$BackupRoot = 'D:\Game\LifePlay_Backup_5.5'
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$lotDir = Join-Path $BackupRoot $Lot
|
|
$manifest = Join-Path $lotDir 'manifest.csv'
|
|
if (-not (Test-Path $manifest)) { throw "Aucun manifeste pour le lot $Lot : $manifest" }
|
|
|
|
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
|
|
$keep = Join-Path $lotDir "_avant-restauration\$stamp"
|
|
$errors = 0
|
|
|
|
foreach ($row in Import-Csv $manifest) {
|
|
if ($Only -and ($Only | ForEach-Object { $_ -replace '^\.\\', '' }) -notcontains $row.Rel) { continue }
|
|
$cur = Join-Path $ProjectRoot $row.Rel
|
|
|
|
if (Test-Path -LiteralPath $cur -PathType Leaf) {
|
|
$k = Join-Path $keep $row.Rel
|
|
if ($PSCmdlet.ShouldProcess($row.Rel, 'conserver la version courante')) {
|
|
New-Item -ItemType Directory -Force (Split-Path $k -Parent) | Out-Null
|
|
Copy-Item -LiteralPath $cur -Destination $k -Force
|
|
}
|
|
}
|
|
|
|
if ($row.Existed -eq 'True') {
|
|
$src = Join-Path $lotDir $row.Rel
|
|
if ($PSCmdlet.ShouldProcess($row.Rel, 'restaurer')) {
|
|
New-Item -ItemType Directory -Force (Split-Path $cur -Parent) | Out-Null
|
|
Copy-Item -LiteralPath $src -Destination $cur -Force
|
|
$h = (Get-FileHash -LiteralPath $cur -Algorithm MD5).Hash
|
|
if ($h -ne $row.MD5) { Write-Warning "MD5 different apres restauration : $($row.Rel)"; $errors++ }
|
|
else { Write-Host "restaure : $($row.Rel) ($h)" }
|
|
}
|
|
} elseif (Test-Path -LiteralPath $cur -PathType Leaf) {
|
|
$dst = Join-Path $lotDir "_retires\$stamp\$($row.Rel)"
|
|
if ($PSCmdlet.ShouldProcess($row.Rel, 'retirer (fichier cree par le lot)')) {
|
|
New-Item -ItemType Directory -Force (Split-Path $dst -Parent) | Out-Null
|
|
Move-Item -LiteralPath $cur -Destination $dst -Force
|
|
Write-Host "retire : $($row.Rel) -> $dst"
|
|
}
|
|
}
|
|
}
|
|
if ($errors) { throw "$errors fichier(s) en echec de verification" }
|
|
Write-Host "Restauration du lot $Lot terminee. Versions remplacees conservees dans $keep"
|