mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Restricts manufacturer folder detection to known OEMs
Improves driver folder discovery logic by explicitly defining recognized manufacturer folder names (Dell, HP, Lenovo, Microsoft) instead of treating any root-level folder with children as a manufacturer folder. Prevents incorrect categorization of non-manufacturer folders at the root level and ensures only legitimate OEM folders are processed for model-specific driver packages. Refactors control flow to eliminate else block, improving code clarity and maintainability.
This commit is contained in:
@@ -1155,6 +1155,7 @@ if ($null -eq $DriverSourcePath) {
|
|||||||
# Build folder list that surfaces Manufacturer\Model entries
|
# Build folder list that surfaces Manufacturer\Model entries
|
||||||
$DriverFolders = Get-ChildItem -Path $DriversPath -Directory
|
$DriverFolders = Get-ChildItem -Path $DriversPath -Directory
|
||||||
$driversRootFullPath = (Get-Item -Path $DriversPath).FullName.TrimEnd('\')
|
$driversRootFullPath = (Get-Item -Path $DriversPath).FullName.TrimEnd('\')
|
||||||
|
$manufacturerFolderNames = @('dell','hp','lenovo','microsoft')
|
||||||
$relativePathResolver = {
|
$relativePathResolver = {
|
||||||
param(
|
param(
|
||||||
[string]$candidatePath,
|
[string]$candidatePath,
|
||||||
@@ -1187,8 +1188,13 @@ if ($null -eq $DriverSourcePath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($driverFolder in $DriverFolders) {
|
foreach ($driverFolder in $DriverFolders) {
|
||||||
|
$parentIsRoot = $driverFolder.Parent.FullName -eq $driversRootFullPath
|
||||||
|
$folderNameLower = $driverFolder.Name.ToLowerInvariant()
|
||||||
|
$isManufacturerFolder = $parentIsRoot -and ($manufacturerFolderNames -contains $folderNameLower)
|
||||||
|
|
||||||
|
if ($isManufacturerFolder) {
|
||||||
|
# Only manufacturer folders (Dell/HP/Lenovo/Microsoft) should surface child model folders.
|
||||||
$childModelFolders = Get-ChildItem -Path $driverFolder.FullName -Directory -ErrorAction SilentlyContinue
|
$childModelFolders = Get-ChildItem -Path $driverFolder.FullName -Directory -ErrorAction SilentlyContinue
|
||||||
if (($childModelFolders.Count -gt 0) -and ($driverFolder.Parent.FullName -eq $driversRootFullPath)) {
|
|
||||||
foreach ($modelFolder in $childModelFolders) {
|
foreach ($modelFolder in $childModelFolders) {
|
||||||
if (-not (Test-DriverFolderHasInstallableContent -Path $modelFolder.FullName)) {
|
if (-not (Test-DriverFolderHasInstallableContent -Path $modelFolder.FullName)) {
|
||||||
WriteLog "Skipping driver folder '$($modelFolder.FullName)' because no installable files were found."
|
WriteLog "Skipping driver folder '$($modelFolder.FullName)' because no installable files were found."
|
||||||
@@ -1201,8 +1207,9 @@ if ($null -eq $DriverSourcePath) {
|
|||||||
RelativePath = $relativePath
|
RelativePath = $relativePath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (-not (Test-DriverFolderHasInstallableContent -Path $driverFolder.FullName)) {
|
if (-not (Test-DriverFolderHasInstallableContent -Path $driverFolder.FullName)) {
|
||||||
WriteLog "Skipping driver folder '$($driverFolder.FullName)' because no installable files were found."
|
WriteLog "Skipping driver folder '$($driverFolder.FullName)' because no installable files were found."
|
||||||
continue
|
continue
|
||||||
@@ -1214,7 +1221,6 @@ if ($null -eq $DriverSourcePath) {
|
|||||||
RelativePath = $relativePath
|
RelativePath = $relativePath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$DriverSourcesCount = $DriverSources.Count
|
$DriverSourcesCount = $DriverSources.Count
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user