From 9bbb40ce8ce8413290bf1d1458f7febaf96cf760 Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Thu, 26 Jun 2025 18:12:35 -0700 Subject: [PATCH] feat: Clean up driver source and obsolete config Automatically deletes the source driver folder after successful compression into a WIM file to conserve disk space. A failure to delete will only log a warning and not interrupt the process. Removes unused 'Make' and 'Model' properties from the UI configuration. --- .../FFU.Common/FFU.Common.Drivers.psm1 | 12 +++++++++ .../FFUUI.Core/FFUUI.Core.Config.psm1 | 26 +++++++++---------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/FFUDevelopment/FFU.Common/FFU.Common.Drivers.psm1 b/FFUDevelopment/FFU.Common/FFU.Common.Drivers.psm1 index 25085ac..99b95e1 100644 --- a/FFUDevelopment/FFU.Common/FFU.Common.Drivers.psm1 +++ b/FFUDevelopment/FFU.Common/FFU.Common.Drivers.psm1 @@ -61,6 +61,18 @@ function Compress-DriverFolderToWim { Invoke-Process -FilePath "dism.exe" -ArgumentList $dismArgs -Wait $true WriteLog "Successfully compressed '$SourceFolderPath' to '$DestinationWimPath' using dism.exe." + + # Remove the source folder after successful compression + WriteLog "Removing source driver folder: $SourceFolderPath" + try { + Remove-Item -Path $SourceFolderPath -Recurse -Force -ErrorAction Stop + WriteLog "Successfully removed source folder '$SourceFolderPath'." + } + catch { + WriteLog "Warning: Failed to remove source folder '$SourceFolderPath'. Error: $($_.Exception.Message)" + # Do not fail the whole operation, just log a warning. + } + return $true # Indicate success } catch { diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Config.psm1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Config.psm1 index beccacc..38be10d 100644 --- a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Config.psm1 +++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Config.psm1 @@ -49,21 +49,21 @@ function Get-UIConfig { InstallWingetApps = $State.Controls.chkInstallWingetApps.IsChecked ISOPath = $State.Controls.txtISOPath.Text LogicalSectorSizeBytes = [int]$State.Controls.cmbLogicalSectorSize.SelectedItem.Content - Make = $State.Controls.cmbMake.SelectedItem + # Make = $null MediaType = $State.Controls.cmbMediaType.SelectedItem Memory = [int64]$State.Controls.txtMemory.Text * 1GB - Model = if ($State.Controls.chkDownloadDrivers.IsChecked) { - $selectedModels = $State.Controls.lstDriverModels.Items | Where-Object { $_.IsSelected } - if ($selectedModels.Count -ge 1) { - $selectedModels[0].Model - } - else { - $null - } - } - else { - $null - } + # Model = if ($State.Controls.chkDownloadDrivers.IsChecked) { + # $selectedModels = $State.Controls.lstDriverModels.Items | Where-Object { $_.IsSelected } + # if ($selectedModels.Count -ge 1) { + # $selectedModels[0].Model + # } + # else { + # $null + # } + # } + # else { + # $null + # } OfficeConfigXMLFile = $State.Controls.txtOfficeConfigXMLFilePath.Text OfficePath = $State.Controls.txtOfficePath.Text Optimize = $State.Controls.chkOptimize.IsChecked