Skip to content

Pre-install and post-install operations#3756

Merged
Martí Climent (marticliment) merged 13 commits intomainfrom
pre-post-install-operations
Jun 20, 2025
Merged

Pre-install and post-install operations#3756
Martí Climent (marticliment) merged 13 commits intomainfrom
pre-post-install-operations

Conversation

@marticliment
Copy link
Collaborator

@marticliment Martí Climent (marticliment) commented Jun 17, 2025

  • Internal changes so operations can have dependencies on other operations.
  • Add the ability to kill process before operation on a package
  • Add the ability to specify preinstall and postinstall operations

fix #1225
fix #2193
fix #3038
fix #3221
fix #2160

fix #3702

@marticliment Martí Climent (marticliment) marked this pull request as ready for review June 20, 2025 10:01

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 PrePostOperation and KillProcessOperation to 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 AbstractOperation to 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 AllowPrePostOps to allowPrePostOps for consistency with C# conventions.
            bool AllowPrePostOps =

src/UniGetUI/AppOperationHelper.cs:148

  • [nitpick] The variable installOp holds an update operation. Consider renaming it to updateOp for clarity.
        public static async Task<AbstractOperation?> UninstallThenReinstall(IPackage? package, TEL_InstallReferral referral)

src/UniGetUI.PackageEngine.Operations/AbstractOperation.cs:212

  • This new _runOperation method 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;
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

The namespace does not match the file path (PackageEngine.Operations). It should be updated to namespace UniGetUI.PackageEngine.Operations to avoid compilation errors.

Suggested change
namespace UniGetUI.PackageOperations;
namespace UniGetUI.PackageEngine.Operations;

Copilot uses AI. Check for mistakes.
private string Payload;
public PrePostOperation(string payload) : base(true)
{
Payload = payload.Replace("\r", "\n").Replace("\n\n", "\n").Replace("\n", "&");
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

Joining multiple commands with & without sanitization may allow injection. Consider validating or escaping Payload to prevent unintended command execution.

Suggested change
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
);

Copilot uses AI. Check for mistakes.
@marticliment Martí Climent (marticliment) merged commit 7574436 into main Jun 20, 2025
2 checks passed
@marticliment Martí Climent (marticliment) deleted the pre-post-install-operations branch July 18, 2025 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants