Skip to content

Commit

Permalink
Force uninstall-then-reinstall operations to always queue, ignoring a…
Browse files Browse the repository at this point in the history
…ny parallel setting (fix #2063)
  • Loading branch information
marticliment committed May 29, 2024
1 parent 990e331 commit 1a2e516
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ private void MenuUninstallThenReinstall_Invoked(object sender, RoutedEventArgs a
var package = PackageList.SelectedItem as Package;
if (!Initialized || package == null)
return;
MainApp.Instance.AddOperationToList(new UninstallPackageOperation(package));
MainApp.Instance.AddOperationToList(new InstallPackageOperation(package));
MainApp.Instance.AddOperationToList(new UninstallPackageOperation(package, IgnoreParallelInstalls: true));
MainApp.Instance.AddOperationToList(new InstallPackageOperation(package, IgnoreParallelInstalls: true));

}
private void MenuIgnorePackage_Invoked(object sender, RoutedEventArgs args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ private void MenuUpdateAfterUninstall_Invoked(object sender, RoutedEventArgs e)
var package = PackageList.SelectedItem as Package;
if (!Initialized || package == null)
return;
MainApp.Instance.AddOperationToList(new UninstallPackageOperation(package));
MainApp.Instance.AddOperationToList(new InstallPackageOperation(package));
MainApp.Instance.AddOperationToList(new UninstallPackageOperation(package, IgnoreParallelInstalls: true));
MainApp.Instance.AddOperationToList(new InstallPackageOperation(package, IgnoreParallelInstalls: true));
}

private void MenuUninstall_Invoked(object sender, RoutedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ public OperationStatus Status
}
}
}
public AbstractOperation()
protected bool IGNORE_PARALLEL_OPERATION_SETTINGS = false;
public AbstractOperation(bool IgnoreParallelInstalls = false)
{
IGNORE_PARALLEL_OPERATION_SETTINGS = IgnoreParallelInstalls;

InitializeComponent();

OutputDialog = new ContentDialog();
Expand Down
18 changes: 9 additions & 9 deletions src/UniGetUI/PackageEngine/Operations/PackageOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public abstract class PackageOperation : AbstractOperation

public Package Package;
protected InstallationOptions Options;
public PackageOperation(Package package, InstallationOptions options)
public PackageOperation(Package package, InstallationOptions options, bool IgnoreParallelInstalls = false) : base(IgnoreParallelInstalls)
{
Package = package;
Options = options;
Expand All @@ -45,7 +45,7 @@ public PackageOperation(Package package, InstallationOptions options)

protected override async Task WaitForAvailability()
{
if (Settings.Get("AllowParallelInstalls") || Settings.Get("AllowParallelInstallsForManager" + Package.Manager.Name))
if (!IGNORE_PARALLEL_OPERATION_SETTINGS && (Settings.Get("AllowParallelInstalls") || Settings.Get($"AllowParallelInstallsForManager{Package.Manager.Name}")))
{
Logger.Debug("Parallel installs are allowed. Skipping queue check");
return;
Expand Down Expand Up @@ -75,14 +75,14 @@ protected override async Task WaitForAvailability()
Package.SetTag(PackageTag.BeingProcessed);
}

public PackageOperation(Package package) : this(package, new InstallationOptions(package)) { }
public PackageOperation(Package package, bool IgnoreParallelInstalls = false) : this(package, new InstallationOptions(package), IgnoreParallelInstalls) { }
}

public class InstallPackageOperation : PackageOperation
{

public InstallPackageOperation(Package package, InstallationOptions options) : base(package, options) { }
public InstallPackageOperation(Package package) : base(package) { }
public InstallPackageOperation(Package package, InstallationOptions options, bool IgnoreParallelInstalls = false) : base(package, options, IgnoreParallelInstalls) { }
public InstallPackageOperation(Package package, bool IgnoreParallelInstalls = false) : base(package, IgnoreParallelInstalls) { }
protected override Process BuildProcessInstance(ProcessStartInfo startInfo)
{
if (Options.RunAsAdministrator || Settings.Get("AlwaysElevate" + Package.Manager.Name))
Expand Down Expand Up @@ -227,8 +227,8 @@ protected override async void Initialize()
public class UpdatePackageOperation : PackageOperation
{

public UpdatePackageOperation(Package package, InstallationOptions options) : base(package, options) { }
public UpdatePackageOperation(Package package) : base(package) { }
public UpdatePackageOperation(Package package, InstallationOptions options, bool IgnoreParallelInstalls = false) : base(package, options, IgnoreParallelInstalls) { }
public UpdatePackageOperation(Package package, bool IgnoreParallelInstalls = false) : base(package, IgnoreParallelInstalls) { }
protected override Process BuildProcessInstance(ProcessStartInfo startInfo)
{
if (Options.RunAsAdministrator || Settings.Get("AlwaysElevate" + Package.Manager.Name))
Expand Down Expand Up @@ -379,8 +379,8 @@ protected override async void Initialize()
public class UninstallPackageOperation : PackageOperation
{

public UninstallPackageOperation(Package package, InstallationOptions options) : base(package, options) { }
public UninstallPackageOperation(Package package) : base(package) { }
public UninstallPackageOperation(Package package, InstallationOptions options, bool IgnoreParallelInstalls = false) : base(package, options, IgnoreParallelInstalls) { }
public UninstallPackageOperation(Package package, bool IgnoreParallelInstalls = false) : base(package, IgnoreParallelInstalls) { }
protected override Process BuildProcessInstance(ProcessStartInfo startInfo)
{
if (Options.RunAsAdministrator || Settings.Get("AlwaysElevate" + Package.Manager.Name))
Expand Down

0 comments on commit 1a2e516

Please sign in to comment.