Refactor WindowsGeneralDrivelution to inherit BaseDriverUpdater - #284
Merged
Conversation
…BaseDriverUpdater - Now inherits BaseDriverUpdater instead of implementing IGeneralDrivelution directly - Only InstallCoreAsync and platform-specific helpers retained - Windows permission check added as a custom pipeline step via GetPipelineSteps - VerifyInstallationAsync override uses pnputil /enum-drivers - RollbackAsync override reinstalls backed-up INF drivers - All retry, timeout, rollback, and event logic inherited from base class - ~550 lines -> ~370 lines (removed duplicated pipeline/validation/error-handling code) Closes #283
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the Windows driver updater implementation to inherit from BaseDriverUpdater, shifting generic pipeline/validation/rollback orchestration into the shared core pipeline while keeping only Windows-specific behavior (permission check, PnPUtil install, INF parsing) in the Windows implementation.
Changes:
WindowsGeneralDrivelutionnow inheritsBaseDriverUpdaterand overridesGetPipelineSteps()to inject an admin permission check step.- Windows-specific install/verify/rollback logic is implemented via
InstallCoreAsync,VerifyInstallationAsync, andRollbackAsyncoverrides (PnPUtil-based). - Driver discovery/parsing is retained for Windows (
*.infdefault + INF metadata/hash/signature extraction).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+67
to
+75
| var psi = new ProcessStartInfo | ||
| { | ||
| throw new DriverPermissionException( | ||
| "Administrator privileges are required for driver updates. " + | ||
| "Please restart the application as administrator."); | ||
| } | ||
| FileName = "pnputil.exe", | ||
| Arguments = "/enum-drivers", | ||
| RedirectStandardOutput = true, | ||
| RedirectStandardError = true, | ||
| UseShellExecute = false, | ||
| CreateNoWindow = true | ||
| }; |
| result.EndTime = DateTime.UtcNow; | ||
| GeneralTracer.Info($"Driver update process ended. Duration: {result.DurationMs}ms, Success: {result.Success}"); | ||
| GeneralTracer.Warn($"Failed to verify driver installation - {ex.Message}"); | ||
| return true; // Non-fatal: don't block the update |
Comment on lines
+129
to
145
| // Reinstall backed-up INF drivers via PnPUtil | ||
| foreach (var infFile in backupFiles.Where( | ||
| f => f.EndsWith(".inf", StringComparison.OrdinalIgnoreCase))) | ||
| { | ||
| if (!await _validator.ValidateSignatureAsync( | ||
| driverInfo.FilePath, | ||
| driverInfo.TrustedPublishers, | ||
| cancellationToken)) | ||
| try | ||
| { | ||
| return false; | ||
| GeneralTracer.Info($"Restoring driver from: {infFile}"); | ||
| await InstallDriverUsingPnPUtilAsync(infFile, cancellationToken); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| GeneralTracer.Warn($"Failed to restore driver from {infFile}: {ex.Message}"); | ||
| } | ||
| } | ||
|
|
||
| // Validate compatibility | ||
| if (!await _validator.ValidateCompatibilityAsync(driverInfo, cancellationToken)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } |
Comment on lines
+133
to
141
| try | ||
| { | ||
| return false; | ||
| GeneralTracer.Info($"Restoring driver from: {infFile}"); | ||
| await InstallDriverUsingPnPUtilAsync(infFile, cancellationToken); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| GeneralTracer.Warn($"Failed to restore driver from {infFile}: {ex.Message}"); | ||
| } |
Comment on lines
+220
to
+222
| return Task.FromResult(PipelineResult.Fail( | ||
| "Administrator privileges are required for driver updates. " + | ||
| "Please restart the application as administrator.")); |
Comment on lines
360
to
364
| if (verParts.Length > 1) | ||
| { | ||
| driverInfo.Version = verParts[1].Trim(); | ||
| } | ||
| if (verParts.Length > 0 && DateTime.TryParse(verParts[0].Trim(), out var releaseDate)) | ||
| { | ||
| if (verParts.Length > 0 | ||
| && DateTime.TryParse(verParts[0].Trim(), out var releaseDate)) | ||
| driverInfo.ReleaseDate = releaseDate; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor the Windows platform driver updater to inherit from \BaseDriverUpdater, eliminating duplicated pipeline, validation, and error-handling code.
Changes
Diff
Why
Completes sub-task 3 of the Drivelution pipeline refactoring. The Windows updater now only contains Windows-specific logic — everything generic is in \BaseDriverUpdater.
Closes #283