diff --git a/scripts/Upload-Image.ps1 b/scripts/Upload-Image.ps1 index d5f02f9..537ecf2 100644 --- a/scripts/Upload-Image.ps1 +++ b/scripts/Upload-Image.ps1 @@ -5,7 +5,10 @@ # 1. Checks the MCL cache before sending anything: # - exactly one -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 {