diff --git a/FFUDevelopment/BuildFFUVM_UI.ps1 b/FFUDevelopment/BuildFFUVM_UI.ps1 index 4fd0b7c..03950df 100644 --- a/FFUDevelopment/BuildFFUVM_UI.ps1 +++ b/FFUDevelopment/BuildFFUVM_UI.ps1 @@ -167,9 +167,9 @@ $window.Add_Closed({ } } - # Garbage collection - [System.GC]::Collect() - [System.GC]::WaitForPendingFinalizers() + # # Garbage collection + # [System.GC]::Collect() + # [System.GC]::WaitForPendingFinalizers() }) [void]$window.ShowDialog() diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Drivers.Dell.psm1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Drivers.Dell.psm1 index 55c68d8..8af929a 100644 --- a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Drivers.Dell.psm1 +++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Drivers.Dell.psm1 @@ -178,41 +178,10 @@ function Save-DellDriversTask { $modelPath = Join-Path -Path $makeDriversPath -ChildPath $modelName try { - # --- Dell Catalog Handling --- + # Define paths for Dell catalog. The catalog is assumed to be prepared by the calling function. $dellDriversFolder = Join-Path -Path $DriversFolder -ChildPath "Dell" $catalogBaseName = if ($WindowsRelease -le 11) { "CatalogPC" } else { "Catalog" } - $dellCabFile = Join-Path -Path $dellDriversFolder -ChildPath "$($catalogBaseName).cab" $dellCatalogXML = Join-Path -Path $dellDriversFolder -ChildPath "$($catalogBaseName).xml" - $catalogUrl = if ($WindowsRelease -le 11) { "http://downloads.dell.com/catalog/CatalogPC.cab" } else { "https://downloads.dell.com/catalog/Catalog.cab" } - - $downloadCatalog = $true - if (Test-Path -Path $dellCatalogXML -PathType Leaf) { - if (((Get-Date) - (Get-Item $dellCatalogXML).LastWriteTime).TotalDays -lt 7) { - WriteLog "Using existing Dell Catalog XML (less than 7 days old): $dellCatalogXML" - $downloadCatalog = $false - } - else { WriteLog "Existing Dell Catalog XML is older than 7 days: $dellCatalogXML" } - } - else { WriteLog "Dell Catalog XML not found: $dellCatalogXML" } - - if ($downloadCatalog) { - WriteLog "Downloading and extracting Dell Catalog for task..." - if (-not (Test-Path -Path $dellDriversFolder -PathType Container)) { - New-Item -Path $dellDriversFolder -ItemType Directory -Force | Out-Null - } - try { - $request = [System.Net.WebRequest]::Create($catalogUrl); $request.Method = 'HEAD'; $response = $request.GetResponse(); $response.Close() - } - catch { throw "Dell Catalog URL '$catalogUrl' not accessible: $($_.Exception.Message)" } - - if (Test-Path -Path $dellCabFile) { Remove-Item -Path $dellCabFile -Force -ErrorAction SilentlyContinue } - if (Test-Path -Path $dellCatalogXML) { Remove-Item -Path $dellCatalogXML -Force -ErrorAction SilentlyContinue } - - Start-BitsTransferWithRetry -Source $catalogUrl -Destination $dellCabFile - Invoke-Process -FilePath "Expand.exe" -ArgumentList """$dellCabFile"" ""$dellCatalogXML""" | Out-Null - Remove-Item -Path $dellCabFile -Force -ErrorAction SilentlyContinue - } - # --- End Dell Catalog Handling --- # 1. Check if drivers already exist for this model (final destination) if (Test-Path -Path $modelPath -PathType Container) { @@ -567,7 +536,6 @@ function Save-DellDriversTask { # Ensure return object is created even on error return [PSCustomObject]@{ Model = $modelName; Status = $status; Success = $success } } - # REMOVED: Finally block that cleaned up temp catalog files # Enqueue the final status (success or error) before returning if ($null -ne $ProgressQueue) { Invoke-ProgressUpdate -ProgressQueue $ProgressQueue -Identifier $modelName -Status $status } diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Drivers.psm1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Drivers.psm1 index 8329091..ddf0388 100644 --- a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Drivers.psm1 +++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Drivers.psm1 @@ -568,6 +568,52 @@ function Invoke-DownloadSelectedDrivers { $State.Controls.txtStatus.Text = "Processing all selected drivers..." WriteLog "Processing all selected drivers: $($selectedDrivers.Model -join ', ')" + # Pre-process Dell Catalog if needed, so it's not done in parallel + if ($selectedDrivers | Where-Object { $_.Make -eq 'Dell' }) { + WriteLog "Dell drivers selected. Ensuring Dell Catalog is up-to-date..." + try { + $dellDriversFolder = Join-Path -Path $localDriversFolder -ChildPath "Dell" + $catalogBaseName = if ($localWindowsRelease -le 11) { "CatalogPC" } else { "Catalog" } + $dellCabFile = Join-Path -Path $dellDriversFolder -ChildPath "$($catalogBaseName).cab" + $dellCatalogXML = Join-Path -Path $dellDriversFolder -ChildPath "$($catalogBaseName).xml" + $catalogUrl = if ($localWindowsRelease -le 11) { "http://downloads.dell.com/catalog/CatalogPC.cab" } else { "https://downloads.dell.com/catalog/Catalog.cab" } + + $downloadCatalog = $true + if (Test-Path -Path $dellCatalogXML -PathType Leaf) { + if (((Get-Date) - (Get-Item $dellCatalogXML).CreationTime).TotalDays -lt 7) { + WriteLog "Using existing Dell Catalog XML (less than 7 days old): $dellCatalogXML" + $downloadCatalog = $false + } + else { WriteLog "Existing Dell Catalog XML is older than 7 days: $dellCatalogXML" } + } + else { WriteLog "Dell Catalog XML not found: $dellCatalogXML" } + + if ($downloadCatalog) { + WriteLog "Downloading and extracting Dell Catalog for driver download process..." + if (-not (Test-Path -Path $dellDriversFolder -PathType Container)) { + New-Item -Path $dellDriversFolder -ItemType Directory -Force | Out-Null + } + + if (Test-Path -Path $dellCabFile) { Remove-Item -Path $dellCabFile -Force -ErrorAction SilentlyContinue } + if (Test-Path -Path $dellCatalogXML) { Remove-Item -Path $dellCatalogXML -Force -ErrorAction SilentlyContinue } + + Start-BitsTransferWithRetry -Source $catalogUrl -Destination $dellCabFile + Invoke-Process -FilePath "Expand.exe" -ArgumentList """$dellCabFile"" ""$dellCatalogXML""" | Out-Null + Remove-Item -Path $dellCabFile -Force -ErrorAction SilentlyContinue + WriteLog "Dell Catalog prepared successfully." + } + } + catch { + $errorMessage = "Failed to prepare Dell Catalog: $($_.Exception.Message)" + WriteLog $errorMessage + [System.Windows.MessageBox]::Show($errorMessage, "Dell Catalog Error", "OK", "Error") + $Button.IsEnabled = $true + $State.Controls.pbOverallProgress.Visibility = 'Collapsed' + $State.Controls.txtStatus.Text = "Driver download cancelled due to Dell Catalog error." + return + } + } + $taskArguments = @{ DriversFolder = $localDriversFolder WindowsRelease = $localWindowsRelease