mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Optimize driver download by checking for existing WIM files
Refactors the driver download logic for all manufacturers to first check for the existence of a final `.wim` archive. If a WIM file is found, the download and processing for that model is skipped, significantly improving performance on subsequent runs. This change also resolves a potential type conversion error when processing driver mapping JSON files and corrects a minor typo in a log message.
This commit is contained in:
@@ -102,23 +102,28 @@ function Save-MicrosoftDriversTask {
|
||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelName -Status "Checking..." }
|
||||
|
||||
try {
|
||||
# Check if drivers already exist for this model
|
||||
# Check if WIM file or driver folder already exist
|
||||
$makeDriversPath = Join-Path -Path $DriversFolder -ChildPath $Make
|
||||
$wimFilePath = Join-Path -Path $makeDriversPath -ChildPath "$($modelName).wim"
|
||||
if (Test-Path -Path $wimFilePath -PathType Leaf) {
|
||||
$status = "Already downloaded (WIM)"
|
||||
WriteLog "Driver WIM for '$modelName' already exists at '$wimFilePath'."
|
||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelName -Status $status }
|
||||
$wimRelativePath = Join-Path -Path $make -ChildPath "$($modelName).wim"
|
||||
return [PSCustomObject]@{ Model = $modelName; Status = $status; Success = $true; DriverPath = $wimRelativePath }
|
||||
}
|
||||
|
||||
$modelPath = Join-Path -Path $makeDriversPath -ChildPath $modelName
|
||||
if (Test-Path -Path $modelPath -PathType Container) {
|
||||
$folderSize = (Get-ChildItem -Path $modelPath -Recurse | Measure-Object -Property Length -Sum -ErrorAction SilentlyContinue).Sum
|
||||
if ($folderSize -gt 1MB) {
|
||||
$status = "Already downloaded"
|
||||
WriteLog "Drivers for '$modelName' already exist in '$modelPath'."
|
||||
# Enqueue this status before returning
|
||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelName -Status $status }
|
||||
# Return success immediately
|
||||
return [PSCustomObject]@{ Model = $modelName; Status = $status; Success = $true; DriverPath = $driverRelativePath }
|
||||
}
|
||||
else {
|
||||
# Status is not set to error here, just log and continue
|
||||
WriteLog "Driver folder '$modelPath' for '$modelName' exists but is empty or very small. Re-downloading."
|
||||
# Allow the process to continue to re-download
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user