mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Introduces an option to retain downloaded ESD files
Adds a new configuration parameter and UI toggle to control whether downloaded Windows ESD files are removed after application. Updates the download process to check for and reuse existing ESD files that match the latest metadata filename, saving bandwidth and time on subsequent executions. Integrates the conditional deletion logic into the shared cleanup module.
This commit is contained in:
@@ -16,12 +16,13 @@ function Invoke-FFUPostBuildCleanup {
|
||||
[bool]$RemoveDrivers = $false,
|
||||
[bool]$RemoveFFU = $false,
|
||||
[bool]$RemoveApps = $false,
|
||||
[bool]$RemoveUpdates = $false
|
||||
[bool]$RemoveUpdates = $false,
|
||||
[bool]$RemoveDownloadedESD = $false
|
||||
)
|
||||
$originalProgressPreference = $ProgressPreference
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
try {
|
||||
WriteLog "CommonCleanup: Starting cleanup (CaptureISO=$RemoveCaptureISO DeployISO=$RemoveDeployISO AppsISO=$RemoveAppsISO Drivers=$RemoveDrivers FFU=$RemoveFFU Apps=$RemoveApps Updates=$RemoveUpdates KBPath=$KBPath)."
|
||||
WriteLog "CommonCleanup: Starting cleanup (CaptureISO=$RemoveCaptureISO DeployISO=$RemoveDeployISO AppsISO=$RemoveAppsISO Drivers=$RemoveDrivers FFU=$RemoveFFU Apps=$RemoveApps Updates=$RemoveUpdates RemoveDownloadedESD=$RemoveDownloadedESD KBPath=$KBPath)."
|
||||
|
||||
# Primary ISO paths (new naming/location)
|
||||
if ($RemoveCaptureISO -and -not [string]::IsNullOrWhiteSpace($CaptureISOPath) -and (Test-Path -LiteralPath $CaptureISOPath)) {
|
||||
@@ -123,6 +124,20 @@ function Invoke-FFUPostBuildCleanup {
|
||||
}
|
||||
}
|
||||
|
||||
# Remove downloaded ESD files from the root path when requested
|
||||
if ($RemoveDownloadedESD -and -not [string]::IsNullOrWhiteSpace($RootPath) -and (Test-Path -LiteralPath $RootPath -PathType Container)) {
|
||||
WriteLog "CommonCleanup: Removing downloaded ESD files in $RootPath"
|
||||
Get-ChildItem -LiteralPath $RootPath -Filter *.esd -File -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
try {
|
||||
WriteLog "CommonCleanup: Removing ESD $($_.FullName)"
|
||||
Remove-Item -LiteralPath $_.FullName -Force -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
WriteLog "CommonCleanup: Failed removing ESD $($_.FullName) : $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WriteLog "CommonCleanup: Completed."
|
||||
}
|
||||
catch {
|
||||
|
||||
Reference in New Issue
Block a user