Upload-Image: accept MCL 2.1 caches; warn on listed updates MCL never downloaded

MCL 2.1.0.1 downloads its seven catalog JSONs again whenever it returns to
its start screen, seconds after writing the finish tag, so every finished
cache failed the newer-than-tag check. Check only the files a run writes for
its selection (OperatingSystem.json, HardwareDriver.json, LanguagePacks.json).

packages.json now lists the KB5043080 checkpoint CU for 24H2, but MCL never
downloads it; say so instead of counting it in the plan.
This commit is contained in:
cproudlock
2026-10-18 09:53:40 -04:00
parent 2dac8d384b
commit 5b9c494da8

View File

@@ -5,7 +5,10 @@
# 1. Checks the MCL cache before sending anything:
# - exactly one <OS>-Production.tag at the cache root (MCL writes it only
# when a run finishes; none = an unfinished or interrupted cache)
# - no Control file newer than that tag (MCL still writing / crashed)
# - OperatingSystem.json / HardwareDriver.json not newer than that tag
# (MCL still writing / crashed). The other Control JSONs are MCL's
# catalogs, which MCL 2.1 downloads again whenever it returns to its
# start screen, so they are newer than the tag in a good cache.
# - the OS in OperatingSystem.json is the one in user_selections.json
# - every Control / Tools JSON is non-empty and parses
# - every WIM, update and driver pack hashes to the SHA-256 MCL's own
@@ -177,8 +180,12 @@ try { $tagTime = New-Object DateTime ([BitConverter]::ToInt64($tagBytes, 0)) }
catch { Stop-Cache @("MCL tag $($tag.Name) holds no valid time. Run MCL again.") }
$tagOs = $tag.BaseName -replace '-(Production|QA)$', ''
# Only the files a run writes for its selection. The catalogs (os.json,
# packages.json, hw_drivers.json, boot.json, ...) are re-downloaded each time
# MCL 2.1 goes back to its start screen, seconds after the tag.
$runFiles = @("OperatingSystem.json", "HardwareDriver.json", "LanguagePacks.json")
$late = @(Get-ChildItem -LiteralPath $ControlPath -File -ErrorAction SilentlyContinue |
Where-Object { $_.LastWriteTime -gt $tagTime.AddSeconds(5) })
Where-Object { $runFiles -contains $_.Name -and $_.LastWriteTime -gt $tagTime.AddSeconds(5) })
if ($late.Count -gt 0) {
Stop-Cache (@("These Control files are newer than the MCL finish tag ($tagTime):") +
($late | ForEach-Object { " $($_.Name) $($_.LastWriteTime)" }) +
@@ -254,6 +261,12 @@ function Get-OsIds { param($e) if ($e.aOsIds) { return @($e.aOsIds) } return @("
$matchedPkgs = @($pkgJson | Where-Object { (Get-OsIds $_) -contains "$selectedOsId" -and $_.enabled -eq 1 })
$pkgTotalSize = [long]0
foreach ($pkg in $matchedPkgs) { $pkgTotalSize += $pkg.size }
# MCL 2.1 lists updates it never downloads (seen: the KB5043080 checkpoint CU).
$missingPkgs = @($matchedPkgs | Where-Object {
$pd = Resolve-DestDir $_.destinationDir
$pr = if ($pd) { Join-Path $pd $_.fileName } else { $_.fileName }
-not (Test-Path -LiteralPath (Join-Path $CachePath $pr) -PathType Leaf)
})
# Drivers: match selected model IDs (family) + OS ID, deduplicate by path
$allMatchingDrivers = @($driverJson | Where-Object {
@@ -284,7 +297,10 @@ Write-Host ""
Write-Host " Upload Plan (from user_selections.json):" -ForegroundColor Cyan
Write-Host " ------------------------------------------"
Write-Host " OS: $($osv.marketingName) $($osv.productName) ($(Format-Size $osTotalSize))" -ForegroundColor Green
Write-Host " Packages: $($matchedPkgs.Count) update(s) ($(Format-Size $pkgTotalSize))" -ForegroundColor Green
Write-Host " Packages: $($matchedPkgs.Count - $missingPkgs.Count) update(s)" -ForegroundColor Green
foreach ($mp in $missingPkgs) {
Write-Host " WARNING: packages.json lists $($mp.fileName) for this OS, but MCL did not download it. Not sent." -ForegroundColor Yellow
}
if ($IncludeDrivers) {
Write-Host " Drivers: $($driverDirs.Count) model(s) ($(Format-Size $driverTotalSize))" -ForegroundColor Green
} else {