Skip to content

Refactor WindowsGeneralDrivelution to inherit BaseDriverUpdater - #284

Merged
JusterZhu merged 1 commit into
masterfrom
feature/refactor-windows-updater-issue-283
May 23, 2026
Merged

Refactor WindowsGeneralDrivelution to inherit BaseDriverUpdater#284
JusterZhu merged 1 commit into
masterfrom
feature/refactor-windows-updater-issue-283

Conversation

@JusterZhu

Copy link
Copy Markdown
Collaborator

Summary

Refactor the Windows platform driver updater to inherit from \BaseDriverUpdater, eliminating duplicated pipeline, validation, and error-handling code.

Changes

  • \WindowsGeneralDrivelution\ now inherits \BaseDriverUpdater\ instead of implementing \IGeneralDrivelution\ directly
  • Windows permission check injected as a custom pipeline step via \GetPipelineSteps()\ override
  • Only \InstallCoreAsync\ (PnPUtil-based installation) and platform-specific helpers retained
  • \VerifyInstallationAsync\ override: uses \pnputil /enum-drivers\
  • \RollbackAsync\ override: reinstalls backed-up INF files via PnPUtil
  • All retry, timeout, event, and unified rollback logic inherited from base

Diff

  • +226 / −458 lines (net −232)

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

…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
Copilot AI review requested due to automatic review settings May 23, 2026 10:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  • WindowsGeneralDrivelution now inherits BaseDriverUpdater and overrides GetPipelineSteps() to inject an admin permission check step.
  • Windows-specific install/verify/rollback logic is implemented via InstallCoreAsync, VerifyInstallationAsync, and RollbackAsync overrides (PnPUtil-based).
  • Driver discovery/parsing is retained for Windows (*.inf default + 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;
@JusterZhu
JusterZhu merged commit 40bf6a1 into master May 23, 2026
1 check passed
@JusterZhu
JusterZhu deleted the feature/refactor-windows-updater-issue-283 branch May 23, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor WindowsGeneralDrivelution to inherit BaseDriverUpdater

2 participants