Download explore/PhaseLatch/scripts/clean_verified_remote_cache.ps1 from Travor278/RheoBench: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/datasets/Travor278/RheoBench/resolve/main/explore/PhaseLatch/scripts/clean_verified_remote_cache.ps1
- Command line
-
hf download hf://datasets/Travor278/RheoBench/explore/PhaseLatch/scripts/clean_verified_remote_cache.ps1
-
curl -L -o clean_verified_remote_cache.ps1 https://huggingface.co/datasets/Travor278/RheoBench/resolve/main/explore/PhaseLatch/scripts/clean_verified_remote_cache.ps1
2.37 kB
| $ErrorActionPreference='Stop' | |
| $plRoot=(Resolve-Path (Join-Path $PSScriptRoot '..')).Path | |
| $plCache=(Resolve-Path (Join-Path $plRoot 'pl03_family/results/poster_raw_frame_cache')).Path | |
| $plLocal=Get-Content (Join-Path $plRoot 'ops/poster_render_cache_manifest.json') -Raw | ConvertFrom-Json | |
| $plRemote=Get-Content (Join-Path $plRoot 'ops/remote_cache_inventory.json') -Raw | ConvertFrom-Json | |
| if($plRemote.root -ne '<QIZHI_ROOT>/codex_remote_ops/phaselatch_tea_20261004/pl03_render_20261009/src/raw_cache'){throw 'Unexpected remote cache root'} | |
| $plByPath=@{} | |
| foreach($plEntry in $plRemote.files){$plByPath[$plEntry.path]=$plEntry} | |
| $plCandidates=@() | |
| foreach($plEntry in $plLocal.files){ | |
| if(-not $plByPath.ContainsKey($plEntry.path)){continue} | |
| $plCopy=$plByPath[$plEntry.path] | |
| if($plCopy.bytes -ne $plEntry.bytes -or $plCopy.sha256 -ne $plEntry.sha256){continue} | |
| $plPath=[IO.Path]::GetFullPath((Join-Path $plCache $plEntry.path)) | |
| if(-not $plPath.StartsWith($plCache+'\',[StringComparison]::OrdinalIgnoreCase) -or [IO.Path]::GetExtension($plPath) -ne '.png'){throw 'Cache path escapes verified directory'} | |
| if(-not (Test-Path -LiteralPath $plPath)){continue} | |
| if((Get-Item -LiteralPath $plPath).Length -ne $plEntry.bytes -or (Get-FileHash -LiteralPath $plPath -Algorithm SHA256).Hash.ToLower() -ne $plEntry.sha256){throw 'Local cache changed'} | |
| $plCandidates+=@{path=$plEntry.path;local_path=$plPath;bytes=$plEntry.bytes;sha256=$plEntry.sha256;remote_path=($plRemote.root+'/'+$plEntry.path)} | |
| } | |
| $plReceipt=Join-Path $plRoot 'ops/render_cache_remote_cleanup.json' | |
| if(Test-Path -LiteralPath $plReceipt){throw 'Cleanup receipt exists; inspect before reusing'} | |
| $plRecord=@{remote_inventory='ops/remote_cache_inventory.json';restore='Fetch each remote_path to local_path and verify recorded SHA256; raw cache only, original replay and final videos untouched.';files=$plCandidates;removed=$false} | |
| $plRecord | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath $plReceipt -Encoding utf8 | |
| foreach($plEntry in $plCandidates){Remove-Item -LiteralPath $plEntry.local_path} | |
| $plRecord.removed=$true | |
| $plRecord.removed_bytes=($plCandidates | Measure-Object -Property bytes -Sum).Sum | |
| $plRecord | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath $plReceipt -Encoding utf8 | |
| Write-Output ('Removed {0} remotely verified cached frames; {1} bytes' -f $plCandidates.Count,$plRecord.removed_bytes) | |