microsoft / CSS-Exchange

Exchange Server support tools and scripts
MIT License
1.21k stars 332 forks source link

[Issue] Update-Engines overwrites the files on 2nd run #2108

Open christophvw opened 2 weeks ago

christophvw commented 2 weeks ago

Describe the issue Update-Engines.ps1 script version 23.11.21.1852 overwrites microsoft_fullpkg.cab when it already exists.

Expected behavior Do not overwrite valid files as the download takes >15min.

proposed fix:

lines 595ff

When the file does not exists - or has a size different size: download it again - otherwise not

if (((Test-Path $fullPkgPath) -ne $true) -or ((Get-Item $fullPkgPath).Length -ne $manifest.ManifestFile.Package.FullPackage.Size)) {
    $wc.DownloadFile($fullPkgUrl, $fullPkgPath)

    # Detect if there are any subdirectories
    # needed for this engine
    $subDirCount = $manifest.ManifestFile.Package.Files.Dir.Count

    for ($i=0; $i -lt $subDirCount; $i++) {
        CreatePath ($fullPkgDir + $manifest.ManifestFile.Package.Files.Dir[$i].name)
    }

    ExtractCab $fullPkgPath $fullPkgDir

    # Copy the downloaded manifest to the package directory
    Copy-Item $manifestPath -Destination $fullPkgDir

    Write-Host "Download Complete: " $engine.Name
}
else {
    Write-Host "Engine already up to date: " $engine.Name
}