Pre-install and post-install operations#3756
Pre-install and post-install operations#3756Martí Climent (marticliment) merged 13 commits intomainfrom
Conversation
…n with a package is performed
… pre/post commands
…ading or uninstalling a package
There was a problem hiding this comment.
Pull Request Overview
This PR extends the operations framework to support pre- and post-operation commands, adds a “kill before operation” feature, and enables operation chaining (e.g., uninstall-then-update or reinstall).
- Introduce
PrePostOperationandKillProcessOperationto the engine and wire them into the UI. - Add UI controls in InstallOptions dialog for selecting processes to close and entering pre/post commands.
- Refactor
AbstractOperationto run inner pre/post operations before and after the main operation.
Reviewed Changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/UniGetUI.PackageEngine.Operations/PrePostOperation.cs | New operation to invoke custom shell commands. |
| src/UniGetUI.PackageEngine.Operations/KillProcessOperation.cs | New operation to close or kill specified processes. |
| src/UniGetUI/Pages/DialogPages/InstallOptions_Package.xaml(.cs) | UI and code-behind for kill-before-operation and pre/post inputs. |
| src/UniGetUI.AppOperationHelper.cs | Added UninstallThenReinstall and UninstallThenUpdate helpers. |
| src/UniGetUI.PackageEngine.Operations/AbstractOperation.cs | Refactored to support inner pre/post operations. |
Comments suppressed due to low confidence (4)
src/UniGetUI/Pages/DialogPages/InstallOptions_Package.xaml.cs:4
- This using directive appears unused in this file. Consider removing it to reduce clutter.
using System.Diagnostics;
src/UniGetUI/Pages/SoftwarePages/PackageBundlesPage.cs:668
- [nitpick] Local variable names should use camelCase. Rename
AllowPrePostOpstoallowPrePostOpsfor consistency with C# conventions.
bool AllowPrePostOps =
src/UniGetUI/AppOperationHelper.cs:148
- [nitpick] The variable
installOpholds an update operation. Consider renaming it toupdateOpfor clarity.
public static async Task<AbstractOperation?> UninstallThenReinstall(IPackage? package, TEL_InstallReferral referral)
src/UniGetUI.PackageEngine.Operations/AbstractOperation.cs:212
- This new
_runOperationmethod introduces complex pre/post logic and error paths. Consider adding unit or integration tests to verify pre-operation failure handling and correct sequencing.
private async Task<OperationVeredict> _runOperation()
| using UniGetUI.Core.Tools; | ||
| using UniGetUI.PackageEngine.Enums; | ||
|
|
||
| namespace UniGetUI.PackageOperations; |
There was a problem hiding this comment.
The namespace does not match the file path (PackageEngine.Operations). It should be updated to namespace UniGetUI.PackageEngine.Operations to avoid compilation errors.
| namespace UniGetUI.PackageOperations; | |
| namespace UniGetUI.PackageEngine.Operations; |
| private string Payload; | ||
| public PrePostOperation(string payload) : base(true) | ||
| { | ||
| Payload = payload.Replace("\r", "\n").Replace("\n\n", "\n").Replace("\n", "&"); |
There was a problem hiding this comment.
Joining multiple commands with & without sanitization may allow injection. Consider validating or escaping Payload to prevent unintended command execution.
| Payload = payload.Replace("\r", "\n").Replace("\n\n", "\n").Replace("\n", "&"); | |
| Payload = System.Text.RegularExpressions.Regex.Replace( | |
| payload.Replace("\r", "\n").Replace("\n\n", "\n").Replace("\n", "&"), | |
| @"[^a-zA-Z0-9_\-\.& ]", | |
| string.Empty | |
| ); |
fix #1225
fix #2193
fix #3038
fix #3221
fix #2160
fix #3702