mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Refactor driver existence check into a common function
Adds a new `Test-ExistingDriver` function to the common driver module to centralize the logic for checking if drivers have already been downloaded, either as a folder or a WIM file. This change removes duplicated code from the Dell, HP, Lenovo, and Microsoft driver download tasks, simplifying maintenance and ensuring consistent behavior across all manufacturers.
This commit is contained in:
@@ -182,8 +182,72 @@ function Update-DriverMappingJson {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# SECTION: Driver Existence Check Function
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
function Test-ExistingDriver {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Make,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Model,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$DriversFolder,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$Identifier,
|
||||||
|
|
||||||
|
[Parameter()]
|
||||||
|
[System.Collections.Concurrent.ConcurrentQueue[hashtable]]$ProgressQueue = $null
|
||||||
|
)
|
||||||
|
|
||||||
|
$makeDriversPath = Join-Path -Path $DriversFolder -ChildPath $Make
|
||||||
|
$modelPath = Join-Path -Path $makeDriversPath -ChildPath $Model
|
||||||
|
$driverRelativePath = Join-Path -Path $Make -ChildPath $Model
|
||||||
|
|
||||||
|
# Check for WIM file first
|
||||||
|
$wimFilePath = Join-Path -Path $makeDriversPath -ChildPath "$($Model).wim"
|
||||||
|
if (Test-Path -Path $wimFilePath -PathType Leaf) {
|
||||||
|
$status = "Already downloaded (WIM)"
|
||||||
|
WriteLog "Driver WIM for '$Identifier' already exists at '$wimFilePath'."
|
||||||
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $Identifier -Status $status }
|
||||||
|
$wimRelativePath = Join-Path -Path $Make -ChildPath "$($Model).wim"
|
||||||
|
return [PSCustomObject]@{
|
||||||
|
Model = $Identifier # Return original identifier
|
||||||
|
Status = $status
|
||||||
|
Success = $true
|
||||||
|
DriverPath = $wimRelativePath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check for existing driver folder
|
||||||
|
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 '$Identifier' already exist in '$modelPath'."
|
||||||
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $Identifier -Status $status }
|
||||||
|
return [PSCustomObject]@{
|
||||||
|
Model = $Identifier # Return original identifier
|
||||||
|
Status = $status
|
||||||
|
Success = $true
|
||||||
|
DriverPath = $driverRelativePath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WriteLog "Driver folder '$modelPath' for '$Identifier' exists but is empty or very small. Re-downloading."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# If neither WIM nor a valid folder exists, return null
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# SECTION: Module Export
|
# SECTION: Module Export
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
|
|
||||||
Export-ModuleMember -Function Compress-DriverFolderToWim, Update-DriverMappingJson
|
Export-ModuleMember -Function Compress-DriverFolderToWim, Update-DriverMappingJson, Test-ExistingDriver
|
||||||
@@ -179,27 +179,14 @@ function Save-DellDriversTask {
|
|||||||
$driverRelativePath = Join-Path -Path $make -ChildPath $modelName # Relative path for the driver folder
|
$driverRelativePath = Join-Path -Path $make -ChildPath $modelName # Relative path for the driver folder
|
||||||
|
|
||||||
try {
|
try {
|
||||||
# Check if WIM file or driver folder already exist
|
# Check for existing drivers
|
||||||
$wimFilePath = Join-Path -Path $makeDriversPath -ChildPath "$($modelName).wim"
|
$existingDriver = Test-ExistingDriver -Make $make -Model $modelName -DriversFolder $DriversFolder -Identifier $modelName -ProgressQueue $ProgressQueue
|
||||||
if (Test-Path -Path $wimFilePath -PathType Leaf) {
|
if ($null -ne $existingDriver) {
|
||||||
$status = "Already downloaded (WIM)"
|
# Add the 'Model' property to the return object for consistency if it's not there
|
||||||
WriteLog "Driver WIM for '$modelName' already exists at '$wimFilePath'."
|
if (-not $existingDriver.PSObject.Properties['Model']) {
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelName -Status $status }
|
$existingDriver | Add-Member -MemberType NoteProperty -Name 'Model' -Value $modelName
|
||||||
$wimRelativePath = Join-Path -Path $make -ChildPath "$($modelName).wim"
|
|
||||||
return [PSCustomObject]@{ Model = $modelName; Status = $status; Success = $true; DriverPath = $wimRelativePath }
|
|
||||||
}
|
|
||||||
|
|
||||||
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'."
|
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelName -Status $status }
|
|
||||||
return [PSCustomObject]@{ Model = $modelName; Status = $status; Success = $true; DriverPath = $driverRelativePath }
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
WriteLog "Driver folder '$modelPath' for '$modelName' exists but is empty/small. Re-downloading."
|
|
||||||
}
|
}
|
||||||
|
return $existingDriver
|
||||||
}
|
}
|
||||||
|
|
||||||
# Define paths for Dell catalog. The catalog is assumed to be prepared by the calling function.
|
# Define paths for Dell catalog. The catalog is assumed to be prepared by the calling function.
|
||||||
|
|||||||
@@ -112,79 +112,50 @@ function Save-HPDriversTask {
|
|||||||
$modelName = $DriverItemData.Model
|
$modelName = $DriverItemData.Model
|
||||||
$make = $DriverItemData.Make # Should be 'HP'
|
$make = $DriverItemData.Make # Should be 'HP'
|
||||||
$identifier = $modelName # Unique identifier for progress updates
|
$identifier = $modelName # Unique identifier for progress updates
|
||||||
|
$sanitizedModelName = $modelName -replace '[\\/:"*?<>|]', '_'
|
||||||
$hpDriversBaseFolder = Join-Path -Path $DriversFolder -ChildPath $make # Changed variable name for clarity
|
$hpDriversBaseFolder = Join-Path -Path $DriversFolder -ChildPath $make # Changed variable name for clarity
|
||||||
$platformListXml = Join-Path -Path $hpDriversBaseFolder -ChildPath "PlatformList.xml"
|
$platformListXml = Join-Path -Path $hpDriversBaseFolder -ChildPath "PlatformList.xml"
|
||||||
$modelSpecificFolder = Join-Path -Path $hpDriversBaseFolder -ChildPath ($modelName -replace '[\\/:"*?<>|]', '_') # Sanitize model name for folder path
|
$modelSpecificFolder = Join-Path -Path $hpDriversBaseFolder -ChildPath $sanitizedModelName # Sanitize model name for folder path
|
||||||
$driverRelativePath = Join-Path -Path $make -ChildPath ($modelName -replace '[\\/:"*?<>|]', '_') # Relative path for the driver folder
|
$driverRelativePath = Join-Path -Path $make -ChildPath $sanitizedModelName # Relative path for the driver folder
|
||||||
$finalStatus = "" # Initialize final status
|
$finalStatus = "" # Initialize final status
|
||||||
$successState = $true # Assume success unless an operation fails
|
$successState = $true # Assume success unless an operation fails
|
||||||
|
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Checking HP drivers for $modelName..." }
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Checking HP drivers for $modelName..." }
|
||||||
|
|
||||||
# Check if WIM file already exists
|
|
||||||
$wimFilePath = Join-Path -Path $hpDriversBaseFolder -ChildPath "$($identifier).wim"
|
|
||||||
if (Test-Path -Path $wimFilePath -PathType Leaf) {
|
|
||||||
$finalStatus = "Already downloaded (WIM)"
|
|
||||||
WriteLog "Driver WIM for '$identifier' already exists at '$wimFilePath'."
|
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status $finalStatus }
|
|
||||||
$wimRelativePath = Join-Path -Path $make -ChildPath "$($identifier).wim"
|
|
||||||
return [PSCustomObject]@{ Identifier = $identifier; Status = $finalStatus; Success = $true; DriverPath = $wimRelativePath }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ensure the base HP folder exists
|
|
||||||
if (-not (Test-Path -Path $hpDriversBaseFolder -PathType Container)) {
|
|
||||||
try {
|
try {
|
||||||
New-Item -Path $hpDriversBaseFolder -ItemType Directory -Force -ErrorAction Stop | Out-Null
|
# Check for existing drivers
|
||||||
WriteLog "Created base HP driver folder: $hpDriversBaseFolder"
|
$existingDriver = Test-ExistingDriver -Make $make -Model $sanitizedModelName -DriversFolder $DriversFolder -Identifier $identifier -ProgressQueue $ProgressQueue
|
||||||
}
|
if ($null -ne $existingDriver) {
|
||||||
catch {
|
# The return object from Test-ExistingDriver uses 'Model' as the identifier key.
|
||||||
$errMsg = "Failed to create base HP driver folder '$hpDriversBaseFolder': $($_.Exception.Message)"
|
# We need to return 'Identifier' for HP's logic.
|
||||||
WriteLog $errMsg
|
$existingDriver | Add-Member -MemberType NoteProperty -Name 'Identifier' -Value $identifier -Force
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Error: Create HP dir failed" }
|
$existingDriver.PSObject.Properties.Remove('Model')
|
||||||
return [PSCustomObject]@{ Identifier = $identifier; Status = "Error: Create HP dir failed"; Success = $false; DriverPath = $null }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if drivers already exist for this model
|
# Special handling for existing folders that need compression
|
||||||
if (Test-Path -Path $modelSpecificFolder -PathType Container) {
|
if ($CompressToWim -and $existingDriver.Status -eq 'Already downloaded') {
|
||||||
WriteLog "HP drivers for '$identifier' already exist in '$modelSpecificFolder'."
|
$wimFilePath = Join-Path -Path $hpDriversBaseFolder -ChildPath "$($sanitizedModelName).wim"
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Found existing HP drivers for $identifier. Verifying..." }
|
$sourceFolderPath = Join-Path -Path $hpDriversBaseFolder -ChildPath $sanitizedModelName
|
||||||
|
WriteLog "Attempting compression of existing folder '$sourceFolderPath' to '$wimFilePath'."
|
||||||
if ($CompressToWim) {
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Compressing existing..." }
|
||||||
$wimFilePath = Join-Path -Path $hpDriversBaseFolder -ChildPath "$($identifier).wim" # WIM in base HP folder, next to model folder
|
|
||||||
WriteLog "Attempting compression of existing folder '$modelSpecificFolder' to '$wimFilePath'."
|
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Compressing existing HP drivers for $identifier..." }
|
|
||||||
try {
|
try {
|
||||||
Compress-DriverFolderToWim -SourceFolderPath $modelSpecificFolder -DestinationWimPath $wimFilePath -WimName $identifier -WimDescription "Drivers for $identifier" -ErrorAction Stop
|
Compress-DriverFolderToWim -SourceFolderPath $sourceFolderPath -DestinationWimPath $wimFilePath -WimName $identifier -WimDescription "Drivers for $identifier" -ErrorAction Stop
|
||||||
$finalStatus = "Already downloaded & Compressed"
|
$existingDriver.Status = "Already downloaded & Compressed"
|
||||||
|
$existingDriver.DriverPath = Join-Path -Path $make -ChildPath "$($sanitizedModelName).wim"
|
||||||
WriteLog "Successfully compressed existing drivers for $identifier to $wimFilePath."
|
WriteLog "Successfully compressed existing drivers for $identifier to $wimFilePath."
|
||||||
$driverRelativePath = Join-Path -Path $make -ChildPath "$($identifier).wim"
|
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
$errMsgForLog = "Error compressing existing drivers for $($identifier): $($_.Exception.Message)"
|
WriteLog "Error compressing existing drivers for $($identifier): $($_.Exception.Message)"
|
||||||
WriteLog $errMsgForLog
|
$existingDriver.Status = "Already downloaded (Compression failed)"
|
||||||
$finalStatus = "Already downloaded (Compression failed: $($_.Exception.Message.Split([Environment]::NewLine)[0]))"
|
|
||||||
# $successState = false # Keep true if folder exists, compression is secondary
|
|
||||||
}
|
}
|
||||||
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status $existingDriver.Status }
|
||||||
}
|
}
|
||||||
else {
|
return $existingDriver
|
||||||
# Not compressing
|
|
||||||
$finalStatus = "Already downloaded"
|
|
||||||
}
|
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status $finalStatus }
|
|
||||||
return [PSCustomObject]@{
|
|
||||||
Identifier = $identifier
|
|
||||||
Status = $finalStatus
|
|
||||||
Success = $successState
|
|
||||||
DriverPath = $driverRelativePath
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# If folder does not exist, proceed with download and extraction
|
# If folder does not exist, proceed with download and extraction
|
||||||
WriteLog "HP drivers for '$identifier' not found locally. Starting download process..."
|
WriteLog "HP drivers for '$identifier' not found locally. Starting download process..."
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Downloading HP drivers for $identifier..." }
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Downloading..." }
|
||||||
|
|
||||||
try {
|
|
||||||
# Ensure PlatformList.xml exists (it should have been downloaded by Get-HPDriversModelList)
|
# Ensure PlatformList.xml exists (it should have been downloaded by Get-HPDriversModelList)
|
||||||
if (-not (Test-Path -Path $platformListXml)) {
|
if (-not (Test-Path -Path $platformListXml)) {
|
||||||
# Attempt to download/extract it again if missing
|
# Attempt to download/extract it again if missing
|
||||||
|
|||||||
@@ -83,42 +83,28 @@ function Save-LenovoDriversTask {
|
|||||||
$identifier = $DriverItemData.Model
|
$identifier = $DriverItemData.Model
|
||||||
$machineType = $DriverItemData.MachineType
|
$machineType = $DriverItemData.MachineType
|
||||||
$make = "Lenovo"
|
$make = "Lenovo"
|
||||||
|
$sanitizedIdentifier = $identifier -replace '[\\/:"*?<>|]', '_'
|
||||||
$status = "Starting..."
|
$status = "Starting..."
|
||||||
$success = $false
|
$success = $false
|
||||||
|
|
||||||
# Define paths
|
# Define paths
|
||||||
$makeDriversPath = Join-Path -Path $DriversFolder -ChildPath $Make
|
$makeDriversPath = Join-Path -Path $DriversFolder -ChildPath $Make
|
||||||
# Use the identifier (which contains the model name and machine type) and sanitize it for the path
|
# Use the identifier (which contains the model name and machine type) and sanitize it for the path
|
||||||
$modelPath = Join-Path -Path $makeDriversPath -ChildPath ($identifier -replace '[\\/:"*?<>|]', '_')
|
$modelPath = Join-Path -Path $makeDriversPath -ChildPath $sanitizedIdentifier
|
||||||
$driverRelativePath = Join-Path -Path $make -ChildPath ($identifier -replace '[\\/:"*?<>|]', '_') # Relative path for the driver folder
|
$driverRelativePath = Join-Path -Path $make -ChildPath $sanitizedIdentifier # Relative path for the driver folder
|
||||||
$tempDownloadPath = Join-Path -Path $makeDriversPath -ChildPath "_TEMP_$($machineType)_$($PID)" # Temp folder for catalog/package XMLs
|
$tempDownloadPath = Join-Path -Path $makeDriversPath -ChildPath "_TEMP_$($machineType)_$($PID)" # Temp folder for catalog/package XMLs
|
||||||
|
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Checking..." }
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status "Checking..." }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
# Check if WIM file or driver folder already exist
|
# Check for existing drivers
|
||||||
$sanitizedIdentifier = $identifier -replace '[\\/:"*?<>|]', '_'
|
$existingDriver = Test-ExistingDriver -Make $make -Model $sanitizedIdentifier -DriversFolder $DriversFolder -Identifier $identifier -ProgressQueue $ProgressQueue
|
||||||
$wimFilePath = Join-Path -Path $makeDriversPath -ChildPath "$($sanitizedIdentifier).wim"
|
if ($null -ne $existingDriver) {
|
||||||
if (Test-Path -Path $wimFilePath -PathType Leaf) {
|
# The return object from Test-ExistingDriver uses 'Model' as the identifier key.
|
||||||
$status = "Already downloaded (WIM)"
|
# We need to return 'Identifier' for Lenovo's logic.
|
||||||
WriteLog "Driver WIM for '$identifier' already exists at '$wimFilePath'."
|
$existingDriver | Add-Member -MemberType NoteProperty -Name 'Identifier' -Value $identifier -Force
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status $status }
|
$existingDriver.PSObject.Properties.Remove('Model')
|
||||||
$wimRelativePath = Join-Path -Path $make -ChildPath "$($sanitizedIdentifier).wim"
|
return $existingDriver
|
||||||
return [PSCustomObject]@{ Identifier = $identifier; Status = $status; Success = $true; DriverPath = $wimRelativePath }
|
|
||||||
}
|
|
||||||
|
|
||||||
# 1. Check if drivers already exist for this model (final destination)
|
|
||||||
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 '$identifier' already exist in '$modelPath'."
|
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $identifier -Status $status }
|
|
||||||
return [PSCustomObject]@{ Identifier = $identifier; Status = $status; Success = $true; DriverPath = $driverRelativePath }
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
WriteLog "Driver folder '$modelPath' for '$identifier' exists but is empty/small. Re-downloading."
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ensure base directories exist
|
# Ensure base directories exist
|
||||||
|
|||||||
@@ -102,29 +102,14 @@ function Save-MicrosoftDriversTask {
|
|||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelName -Status "Checking..." }
|
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelName -Status "Checking..." }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
# Check if WIM file or driver folder already exist
|
# Check for existing drivers
|
||||||
$makeDriversPath = Join-Path -Path $DriversFolder -ChildPath $Make
|
$existingDriver = Test-ExistingDriver -Make $make -Model $modelName -DriversFolder $DriversFolder -Identifier $modelName -ProgressQueue $ProgressQueue
|
||||||
$wimFilePath = Join-Path -Path $makeDriversPath -ChildPath "$($modelName).wim"
|
if ($null -ne $existingDriver) {
|
||||||
if (Test-Path -Path $wimFilePath -PathType Leaf) {
|
# Add the 'Model' property to the return object for consistency if it's not there
|
||||||
$status = "Already downloaded (WIM)"
|
if (-not $existingDriver.PSObject.Properties['Model']) {
|
||||||
WriteLog "Driver WIM for '$modelName' already exists at '$wimFilePath'."
|
$existingDriver | Add-Member -MemberType NoteProperty -Name 'Model' -Value $modelName
|
||||||
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'."
|
|
||||||
if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelName -Status $status }
|
|
||||||
return [PSCustomObject]@{ Model = $modelName; Status = $status; Success = $true; DriverPath = $driverRelativePath }
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
WriteLog "Driver folder '$modelPath' for '$modelName' exists but is empty or very small. Re-downloading."
|
|
||||||
}
|
}
|
||||||
|
return $existingDriver
|
||||||
}
|
}
|
||||||
|
|
||||||
### GET THE DOWNLOAD LINK
|
### GET THE DOWNLOAD LINK
|
||||||
|
|||||||
Reference in New Issue
Block a user