mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Standardize driver compression status reporting across vendors
Updates compression workflow to use consistent status messaging and better error handling across all driver vendor modules (Dell, HP, Lenovo, Microsoft). Changes improve status tracking by: - Standardizing compression success status to "Compression successful" instead of vendor-specific messages - Introducing relative path variables to reduce code duplication and improve maintainability - Suppressing command output by piping to `$null` for cleaner execution - Adding explicit failure state in exception handlers to ensure success property reflects actual outcome - Updating parallel processing logic to recognize the new standardized compression status These modifications ensure consistent behavior across vendors and make the parallel processing coordinator aware of all compression completion states.
This commit is contained in:
@@ -269,7 +269,7 @@ function Invoke-ParallelProcessing {
|
|||||||
else {
|
else {
|
||||||
# Fallback for any task that *still* doesn't return 'Success'. This is now the exceptional case.
|
# Fallback for any task that *still* doesn't return 'Success'. This is now the exceptional case.
|
||||||
WriteLog "Warning: Task for '$taskSpecificIdentifier' did not return a 'Success' property. Inferring from status: '$($taskResult.Status)'"
|
WriteLog "Warning: Task for '$taskSpecificIdentifier' did not return a 'Success' property. Inferring from status: '$($taskResult.Status)'"
|
||||||
if ($taskResult.Status -like 'Completed*' -or $taskResult.Status -like 'Already downloaded*') {
|
if ($taskResult.Status -like 'Completed*' -or $taskResult.Status -like 'Already downloaded*' -or $taskResult.Status -like 'Compression successful*') {
|
||||||
$resultCode = 0 # Treat as success
|
$resultCode = 0 # Treat as success
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -157,17 +157,19 @@ function Save-DellDriversTask {
|
|||||||
}
|
}
|
||||||
if ($CompressToWim -and $existing.Status -eq 'Already downloaded') {
|
if ($CompressToWim -and $existing.Status -eq 'Already downloaded') {
|
||||||
$wimPath = Join-Path $makeDriversPath "$sanitizedModelName.wim"
|
$wimPath = Join-Path $makeDriversPath "$sanitizedModelName.wim"
|
||||||
|
$wimRelativePath = Join-Path $make "$sanitizedModelName.wim"
|
||||||
$srcPath = Join-Path $makeDriversPath $sanitizedModelName
|
$srcPath = Join-Path $makeDriversPath $sanitizedModelName
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelDisplay -Status 'Compressing existing...' }
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelDisplay -Status 'Compressing existing...' }
|
||||||
try {
|
try {
|
||||||
Compress-DriverFolderToWim -SourceFolderPath $srcPath -DestinationWimPath $wimPath -WimName $modelDisplay -WimDescription "Drivers for $modelDisplay" -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
$null = Compress-DriverFolderToWim -SourceFolderPath $srcPath -DestinationWimPath $wimPath -WimName $modelDisplay -WimDescription "Drivers for $modelDisplay" -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
||||||
$existing.Status = 'Already downloaded & Compressed'
|
$existing.Status = 'Compression successful'
|
||||||
$existing.DriverPath = Join-Path $make "$sanitizedModelName.wim"
|
$existing.DriverPath = $wimRelativePath
|
||||||
$existing.Success = $true
|
$existing.Success = $true
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
WriteLog "Compression failed for $($modelDisplay): $($_.Exception.Message)"
|
WriteLog "Compression failed for $($modelDisplay): $($_.Exception.Message)"
|
||||||
$existing.Status = 'Already downloaded (Compression failed)'
|
$existing.Status = 'Already downloaded (Compression failed)'
|
||||||
|
$existing.Success = $false
|
||||||
}
|
}
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelDisplay -Status $existing.Status }
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelDisplay -Status $existing.Status }
|
||||||
}
|
}
|
||||||
@@ -341,7 +343,7 @@ function Save-DellDriversTask {
|
|||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelDisplay -Status 'Compressing...' }
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelDisplay -Status 'Compressing...' }
|
||||||
$wimPath = Join-Path $makeDriversPath "$sanitizedModelName.wim"
|
$wimPath = Join-Path $makeDriversPath "$sanitizedModelName.wim"
|
||||||
try {
|
try {
|
||||||
Compress-DriverFolderToWim -SourceFolderPath $modelPath -DestinationWimPath $wimPath -WimName $modelDisplay -WimDescription $modelDisplay -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
$null = Compress-DriverFolderToWim -SourceFolderPath $modelPath -DestinationWimPath $wimPath -WimName $modelDisplay -WimDescription $modelDisplay -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
||||||
$driverRelativePath = Join-Path $make "$sanitizedModelName.wim"
|
$driverRelativePath = Join-Path $make "$sanitizedModelName.wim"
|
||||||
$statusFinal = 'Completed & Compressed'
|
$statusFinal = 'Completed & Compressed'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,13 +179,14 @@ function Save-HPDriversTask {
|
|||||||
# Special handling for existing folders that need compression
|
# Special handling for existing folders that need compression
|
||||||
if ($CompressToWim -and $existingDriver.Status -eq 'Already downloaded') {
|
if ($CompressToWim -and $existingDriver.Status -eq 'Already downloaded') {
|
||||||
$wimFilePath = Join-Path -Path $hpDriversBaseFolder -ChildPath "$($sanitizedModelName).wim"
|
$wimFilePath = Join-Path -Path $hpDriversBaseFolder -ChildPath "$($sanitizedModelName).wim"
|
||||||
|
$wimRelativePath = Join-Path -Path $make -ChildPath "$($sanitizedModelName).wim"
|
||||||
$sourceFolderPath = Join-Path -Path $hpDriversBaseFolder -ChildPath $sanitizedModelName
|
$sourceFolderPath = Join-Path -Path $hpDriversBaseFolder -ChildPath $sanitizedModelName
|
||||||
WriteLog "Attempting compression of existing folder '$sourceFolderPath' to '$wimFilePath'."
|
WriteLog "Attempting compression of existing folder '$sourceFolderPath' to '$wimFilePath'."
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Compressing existing..." }
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Compressing existing..." }
|
||||||
try {
|
try {
|
||||||
Compress-DriverFolderToWim -SourceFolderPath $sourceFolderPath -DestinationWimPath $wimFilePath -WimName $identifier -WimDescription "Drivers for $identifier" -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
$null = Compress-DriverFolderToWim -SourceFolderPath $sourceFolderPath -DestinationWimPath $wimFilePath -WimName $identifier -WimDescription "Drivers for $identifier" -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
||||||
$existingDriver.Status = "Already downloaded & Compressed"
|
$existingDriver.Status = "Compression successful"
|
||||||
$existingDriver.DriverPath = Join-Path -Path $make -ChildPath "$($sanitizedModelName).wim"
|
$existingDriver.DriverPath = $wimRelativePath
|
||||||
$existingDriver.Success = $true
|
$existingDriver.Success = $true
|
||||||
WriteLog "Successfully compressed existing drivers for $identifier to $wimFilePath."
|
WriteLog "Successfully compressed existing drivers for $identifier to $wimFilePath."
|
||||||
}
|
}
|
||||||
@@ -407,7 +408,7 @@ function Save-HPDriversTask {
|
|||||||
$wimFilePath = Join-Path -Path $hpDriversBaseFolder -ChildPath "$($identifier).wim"
|
$wimFilePath = Join-Path -Path $hpDriversBaseFolder -ChildPath "$($identifier).wim"
|
||||||
WriteLog "Compressing '$modelSpecificFolder' to '$wimFilePath'..."
|
WriteLog "Compressing '$modelSpecificFolder' to '$wimFilePath'..."
|
||||||
try {
|
try {
|
||||||
Compress-DriverFolderToWim -SourceFolderPath $modelSpecificFolder -DestinationWimPath $wimFilePath -WimName $identifier -WimDescription "Drivers for $identifier" -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
$null = Compress-DriverFolderToWim -SourceFolderPath $modelSpecificFolder -DestinationWimPath $wimFilePath -WimName $identifier -WimDescription "Drivers for $identifier" -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
||||||
WriteLog "Compression successful for '$identifier'."
|
WriteLog "Compression successful for '$identifier'."
|
||||||
$finalStatus = "Completed & Compressed"
|
$finalStatus = "Completed & Compressed"
|
||||||
$driverRelativePath = Join-Path -Path $make -ChildPath "$($identifier).wim" # Update relative path to the WIM
|
$driverRelativePath = Join-Path -Path $make -ChildPath "$($identifier).wim" # Update relative path to the WIM
|
||||||
|
|||||||
@@ -132,13 +132,14 @@ function Save-LenovoDriversTask {
|
|||||||
# Special handling for existing folders that need compression
|
# Special handling for existing folders that need compression
|
||||||
if ($CompressToWim -and $existingDriver.Status -eq 'Already downloaded') {
|
if ($CompressToWim -and $existingDriver.Status -eq 'Already downloaded') {
|
||||||
$wimFilePath = Join-Path -Path $makeDriversPath -ChildPath "$($sanitizedIdentifier).wim"
|
$wimFilePath = Join-Path -Path $makeDriversPath -ChildPath "$($sanitizedIdentifier).wim"
|
||||||
|
$wimRelativePath = Join-Path -Path $make -ChildPath "$($sanitizedIdentifier).wim"
|
||||||
$sourceFolderPath = Join-Path -Path $makeDriversPath -ChildPath $sanitizedIdentifier
|
$sourceFolderPath = Join-Path -Path $makeDriversPath -ChildPath $sanitizedIdentifier
|
||||||
WriteLog "Attempting compression of existing folder '$sourceFolderPath' to '$wimFilePath'."
|
WriteLog "Attempting compression of existing folder '$sourceFolderPath' to '$wimFilePath'."
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Compressing existing..." }
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Compressing existing..." }
|
||||||
try {
|
try {
|
||||||
Compress-DriverFolderToWim -SourceFolderPath $sourceFolderPath -DestinationWimPath $wimFilePath -WimName $identifier -WimDescription "Drivers for $identifier" -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
$null = Compress-DriverFolderToWim -SourceFolderPath $sourceFolderPath -DestinationWimPath $wimFilePath -WimName $identifier -WimDescription "Drivers for $identifier" -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
||||||
$existingDriver.Status = "Already downloaded & Compressed"
|
$existingDriver.Status = "Compression successful"
|
||||||
$existingDriver.DriverPath = Join-Path -Path $make -ChildPath "$($sanitizedIdentifier).wim"
|
$existingDriver.DriverPath = $wimRelativePath
|
||||||
$existingDriver.Success = $true
|
$existingDriver.Success = $true
|
||||||
WriteLog "Successfully compressed existing drivers for $identifier to $wimFilePath."
|
WriteLog "Successfully compressed existing drivers for $identifier to $wimFilePath."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,13 +123,14 @@ function Save-MicrosoftDriversTask {
|
|||||||
if ($CompressToWim -and $existingDriver.Status -eq 'Already downloaded') {
|
if ($CompressToWim -and $existingDriver.Status -eq 'Already downloaded') {
|
||||||
$makeDriversPath = Join-Path -Path $DriversFolder -ChildPath $make
|
$makeDriversPath = Join-Path -Path $DriversFolder -ChildPath $make
|
||||||
$wimFilePath = Join-Path -Path $makeDriversPath -ChildPath "$($modelName).wim"
|
$wimFilePath = Join-Path -Path $makeDriversPath -ChildPath "$($modelName).wim"
|
||||||
|
$wimRelativePath = Join-Path -Path $make -ChildPath "$($modelName).wim"
|
||||||
$sourceFolderPath = Join-Path -Path $makeDriversPath -ChildPath $modelName
|
$sourceFolderPath = Join-Path -Path $makeDriversPath -ChildPath $modelName
|
||||||
WriteLog "Attempting compression of existing folder '$sourceFolderPath' to '$wimFilePath'."
|
WriteLog "Attempting compression of existing folder '$sourceFolderPath' to '$wimFilePath'."
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelName -Status "Compressing existing..." }
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelName -Status "Compressing existing..." }
|
||||||
try {
|
try {
|
||||||
Compress-DriverFolderToWim -SourceFolderPath $sourceFolderPath -DestinationWimPath $wimFilePath -WimName $modelName -WimDescription "Drivers for $modelName" -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
$null = Compress-DriverFolderToWim -SourceFolderPath $sourceFolderPath -DestinationWimPath $wimFilePath -WimName $modelName -WimDescription "Drivers for $modelName" -PreserveSource:$PreserveSourceOnCompress -ErrorAction Stop
|
||||||
$existingDriver.Status = "Already downloaded & Compressed"
|
$existingDriver.Status = "Compression successful"
|
||||||
$existingDriver.DriverPath = Join-Path -Path $make -ChildPath "$($modelName).wim"
|
$existingDriver.DriverPath = $wimRelativePath
|
||||||
$existingDriver.Success = $true
|
$existingDriver.Success = $true
|
||||||
WriteLog "Successfully compressed existing drivers for $modelName to $wimFilePath."
|
WriteLog "Successfully compressed existing drivers for $modelName to $wimFilePath."
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user