Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/IPC.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ Every operation payload carries `systemRestartRequired`: `true` when the operati
the machine must be restarted before the change takes effect. See
[Pending machine restarts](#pending-machine-restarts).

A failed update also carries `updateRefusedByPublisher`: `true` when the package manager refused the
update because the package's publisher requires it to be updated another way (WinGet's
`UpgradeBehavior: deny`). Retrying cannot succeed; `package ignored add` stops it from being offered.

| Method | Path | Auth | Parameters/body | CLI equivalent |
| --- | --- | --- | --- | --- |
| `GET` | `/uniget/v1/operations` | Yes | None | `operation list` |
Expand Down
1 change: 1 addition & 0 deletions src/Languages/lang_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,7 @@
"{package} may already be up to date, or no installer matches this system": "{package} may already be up to date, or no installer matches this system",
"{package} could not be updated because its package source was busy or unreachable. Try again in a few minutes": "{package} could not be updated because its package source was busy or unreachable. Try again in a few minutes",
"{package} is currently running. Close it and try again": "{package} is currently running. Close it and try again",
"WinGet cannot update {package}. Its publisher requires updating it another way, for example from within the app itself": "WinGet cannot update {package}. Its publisher requires updating it another way, for example from within the app itself",
"{package} Uninstall": "{package} Uninstall",
"{0} is being uninstalled": "{0} is being uninstalled",
"Uninstall succeeded": "Uninstall succeeded",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using UniGetUI.Interface;
using UniGetUI.PackageEngine.Classes.Packages.Classes;
using UniGetUI.PackageEngine.Enums;
using UniGetUI.PackageEngine.Operations;
using UniGetUI.PackageEngine.Operations.History;
using UniGetUI.PackageOperations;

Expand Down Expand Up @@ -118,7 +119,8 @@ public static void Add(AbstractOperation op)
public static void RetryFailed()
{
var failed = OperationViewModels
.Where(vm => vm.Operation.Status is OperationStatus.Failed)
.Where(vm => vm.Operation.Status is OperationStatus.Failed
&& PackageOperation.IsWorthRetryingInBulk(vm.Operation))
.ToList();
foreach (var vm in failed)
vm.Operation.Retry(AbstractOperation.RetryMode.Retry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using UniGetUI.PackageEngine.Enums;
using UniGetUI.PackageEngine.Operations;
using UniGetUI.PackageEngine.PackageClasses;
using UniGetUI.PackageEngine.PackageLoader;
using UniGetUI.PackageOperations;

namespace UniGetUI.Avalonia.ViewModels;
Expand Down Expand Up @@ -293,6 +294,10 @@ private void RebuildMenu(OperationStatus status)
}
else
{
if (Operation is PackageOperation ignorableOp && PackageOperation.CanIgnoreUpdatesAfterFailure(ignorableOp))
OpMenu.Items.Add(Item("Ignore updates for this package", "pin.svg", true,
() => _ = UpgradablePackagesLoader.Instance.IgnoreUpdatesAsync(ignorableOp.Package)));

OpMenu.Items.Add(Item("Retry", "reload.svg", true,
() => Operation.Retry(AbstractOperation.RetryMode.Retry)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using UniGetUI.Core.Tools;
using UniGetUI.PackageEngine.Enums;
using UniGetUI.PackageEngine.Operations;
using UniGetUI.PackageEngine.PackageLoader;
using UniGetUI.PackageOperations;

namespace UniGetUI.Avalonia.Views.DialogPages;
Expand Down Expand Up @@ -41,11 +42,13 @@ public OperationFailedDialog(AbstractOperation operation)
};
closeButton.Click += (_, _) => Close();

var retryButton = BuildRetryButton(operation);
var primaryButton = operation is PackageOperation pkgOp && PackageOperation.CanIgnoreUpdatesAfterFailure(pkgOp)
? BuildIgnoreUpdatesButton(pkgOp)
: BuildRetryButton(operation);

ButtonsLayout.Children.Add(retryButton);
ButtonsLayout.Children.Add(primaryButton);
ButtonsLayout.Children.Add(closeButton);
Grid.SetColumn(retryButton, 0);
Grid.SetColumn(primaryButton, 0);
Grid.SetColumn(closeButton, 1);
}

Expand Down Expand Up @@ -82,6 +85,30 @@ protected override void OnOpened(EventArgs e)
Dispatcher.UIThread.Post(OutputText.ScrollToBottom, DispatcherPriority.Background);
}

private Control BuildIgnoreUpdatesButton(PackageOperation operation)
{
var button = new SplitButton
{
Content = CoreTools.Translate("Ignore updates for this package"),
HorizontalAlignment = HorizontalAlignment.Stretch,
HorizontalContentAlignment = HorizontalAlignment.Center,
Classes = { "operation-dialog-action" },
};
button.Click += async (_, _) =>
{
Close();
await UpgradablePackagesLoader.Instance.IgnoreUpdatesAsync(operation.Package);
};

var flyout = new MenuFlyout();
flyout.Items.Add(MenuItem(CoreTools.Translate("Retry"),
() => { operation.Retry(AbstractOperation.RetryMode.Retry); Close(); }));
foreach (var item in CollectRetryMenuItems(operation))
flyout.Items.Add(item);
button.Flyout = flyout;
return button;
}

private Control BuildRetryButton(AbstractOperation operation)
{
var retryOptions = CollectRetryMenuItems(operation);
Expand Down
18 changes: 4 additions & 14 deletions src/UniGetUI.Avalonia/Views/SoftwarePages/SoftwareUpdatesPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ protected override void GenerateToolBar(PackagesPageViewModel vm)
if (MainWindow.Instance is not { } window
|| !await IgnoreUpdatesConfirmationDialog.ConfirmAsync(window, packages)) return;
foreach (var pkg in packages)
{
await pkg.AddToIgnoredUpdatesAsync();
UpgradablePackagesLoader.Instance.Remove(pkg);
UpgradablePackagesLoader.Instance.IgnoredPackages[pkg.Id] = pkg;
}
await UpgradablePackagesLoader.Instance.IgnoreUpdatesAsync(pkg);
});
EnableWhen(ignoreButton, () => HasCheckedPackages);
ViewModel.AddToolbarButton("clipboard_list", CoreTools.Translate("Manage ignored updates"),
Expand Down Expand Up @@ -208,9 +204,7 @@ protected override void GenerateToolBar(PackagesPageViewModel vm)
{
var pkg = SelectedItem;
if (pkg is null) return;
_ = pkg.AddToIgnoredUpdatesAsync();
UpgradablePackagesLoader.Instance.Remove(pkg);
UpgradablePackagesLoader.Instance.IgnoredPackages[pkg.Id] = pkg;
_ = UpgradablePackagesLoader.Instance.IgnoreUpdatesAsync(pkg);
};

var menuSkipVersion = new MenuItem
Expand All @@ -222,9 +216,7 @@ protected override void GenerateToolBar(PackagesPageViewModel vm)
{
var pkg = SelectedItem;
if (pkg is null) return;
_ = pkg.AddToIgnoredUpdatesAsync(pkg.NewVersionString);
UpgradablePackagesLoader.Instance.Remove(pkg);
UpgradablePackagesLoader.Instance.IgnoredPackages[pkg.Id] = pkg;
_ = UpgradablePackagesLoader.Instance.IgnoreUpdatesAsync(pkg, pkg.NewVersionString);
};

// ── Pause updates submenu ──────────────────────────────────────────
Expand All @@ -251,9 +243,7 @@ protected override void GenerateToolBar(PackagesPageViewModel vm)
{
var pkg = SelectedItem;
if (pkg is null) return;
_ = pkg.AddToIgnoredUpdatesAsync("<" + t.GetDateFromNow());
UpgradablePackagesLoader.Instance.IgnoredPackages[pkg.Id] = pkg;
UpgradablePackagesLoader.Instance.Remove(pkg);
_ = UpgradablePackagesLoader.Instance.IgnoreUpdatesAsync(pkg, "<" + t.GetDateFromNow());
};
menuPause.Items.Add(item);
}
Expand Down
5 changes: 5 additions & 0 deletions src/UniGetUI.Interface.IpcApi/IpcOperationApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class IpcOperationInfo
public bool CanForget { get; set; }
public IReadOnlyList<string> AvailableQueueActions { get; set; } = [];
public IReadOnlyList<string> AvailableRetryModes { get; set; } = [];
public bool UpdateRefusedByPublisher { get; set; }
public IpcPackageInfo? Package { get; set; }
public string ManagerName { get; set; } = "";
public string SourceName { get; set; } = "";
Expand Down Expand Up @@ -217,6 +218,7 @@ public static IpcOperationDetails GetOperation(string operationId)
CanForget = info.CanForget,
AvailableQueueActions = info.AvailableQueueActions,
AvailableRetryModes = info.AvailableRetryModes,
UpdateRefusedByPublisher = info.UpdateRefusedByPublisher,
Package = info.Package,
ManagerName = info.ManagerName,
SourceName = info.SourceName,
Expand Down Expand Up @@ -359,6 +361,9 @@ private static IpcOperationInfo CreateOperationInfo(TrackedOperation tracked)
? ["run-now", "run-next", "run-last"]
: [],
AvailableRetryModes = !IsActive(operation.Status) ? GetRetryModes(operation) : [],
UpdateRefusedByPublisher =
operation is PackageOperation packageOperation
&& PackageOperation.CanIgnoreUpdatesAfterFailure(packageOperation),
Package = GetOperationPackage(operation),
ManagerName = GetManagerName(operation),
SourceName = GetSourceName(operation),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@ OperationType operation
);

public string? GetReinstallRefusal(IPackage package, InstallOptions options);

public bool UpdateWasRefusedByPublisher(IReadOnlyList<string> processOutput, int returnCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ WinGetTable table in WinGetTableLayout.ReadTables(
InstalledVersionIsUnverified = versionUnknown,
};
// Skip one-shot suppression for unknown versions so the restored mark isn't cleared.
if (
versionUnknown
|| !WinGetPkgOperationHelper.ConsumeAlreadyUpgradedSuppression(package)
)
bool suppressed = versionUnknown
? WinGetPkgOperationHelper.IsStuckUpgradeLoop(package)
: WinGetPkgOperationHelper.ConsumeAlreadyUpgradedSuppression(package);
if (!suppressed)
{
packages.Add(package);
}
else
{
Logger.Warn(
$"WinGet package {package.Id} not being shown as an updated as this version has already been marked as installed"
$"WinGet package {package.Id} not being shown as an update to {package.NewVersionString}, since it is suppressed"
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,19 @@ operation is OperationType.Uninstall
return OperationVeredict.Failure;
}

if (ReportedUpdateNotSupported(returnCode))
{
if (operation is OperationType.Update)
{
Logger.Warn(
$"WinGet refuses to update {package.Id}: its manifest says it must be updated another way; "
+ $"hiding the update to {package.NewVersionString} until a newer version is available"
);
SuppressPhantomUpgrade(package);
Comment thread
GabrielDuf marked this conversation as resolved.
Resolved
}
return OperationVeredict.Failure;
}

if (ReportedUpdateNotApplicable(processOutput, returnCode))
{ // The update is not applicable to the platform
// The scope/architecture we forced may exclude the only installer the package ships
Expand Down Expand Up @@ -941,6 +954,26 @@ internal static bool ReportedDifferentInstallTechnology(IEnumerable<string> proc
)
);

internal static bool ReportedUpdateNotSupported(int returnCode) =>
(uint)returnCode is 0x8A150114;

public override bool UpdateWasRefusedByPublisher(IReadOnlyList<string> processOutput, int returnCode) =>
ReportedUpdateNotSupported(returnCode);

public override string? GetFailureExplanation(
IPackage package,
OperationType operation,
IReadOnlyList<string> processOutput,
int returnCode,
InstallOptions? options = null
) =>
operation is OperationType.Update && ReportedUpdateNotSupported(returnCode)
? CoreTools.Translate(
"WinGet cannot update {package}. Its publisher requires updating it another way, for example from within the app itself",
new Dictionary<string, object?> { { "package", package.Name } }
)
: null;

internal static bool ReportedApplicationCurrentlyRunning(int returnCode) =>
(uint)returnCode is 0x8A150101 or 0x8A150103 or 0x8A150111;

Expand Down
12 changes: 12 additions & 0 deletions src/UniGetUI.PackageEngine.Operations/PackageOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ internal void AdoptReinstallStepFailure()
}
internal bool IsReinstallStep { get; init; }
public bool FailedBecauseApplicationRunning { get; private set; }
public bool FailedBecauseUpdateNotSupported { get; private set; }
public Task SuccessHandled { get; private set; } = Task.CompletedTask;
private IReadOnlyList<string> _closeRunningAppProcessNames = [];
private readonly List<string> _brokerKillBeforeOperationAdded = [];
Expand Down Expand Up @@ -1225,6 +1226,7 @@ List<string> Output
);

FailedBecauseApplicationRunning = false;
FailedBecauseUpdateNotSupported = false;
Metadata.FailureTitle = _genericFailureTitle;
Metadata.FailureMessage = _genericFailureMessage;
if (veredict is OperationVeredict.Failure)
Expand All @@ -1241,7 +1243,11 @@ List<string> Output
)
Metadata.FailureMessage = explanation;
if (CommandRole is OperationType.Update)
{
ExplainNotApplicableUpdate(Output, ReturnCode);
FailedBecauseUpdateNotSupported =
Package.Manager.OperationHelper.UpdateWasRefusedByPublisher(Output, ReturnCode);
}
ExplainInstallerHashMismatch(ReturnCode);
ExplainApplicationCurrentlyRunning(Output, ReturnCode);
ExplainFileInUse(Output);
Expand Down Expand Up @@ -1465,6 +1471,12 @@ private void ExplainNotApplicableUpdate(List<string> output, int returnCode)
#endif
}

public static bool CanIgnoreUpdatesAfterFailure(PackageOperation operation) =>
operation.FailedBecauseUpdateNotSupported;

public static bool IsWorthRetryingInBulk(AbstractOperation operation) =>
operation is not PackageOperation { FailedBecauseUpdateNotSupported: true };

private void ExplainInstallerHashMismatch(int returnCode)
{
#if WINDOWS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public UpgradablePackagesLoader(IReadOnlyList<IPackageManager> managers)
Instance = this;
}

public async Task IgnoreUpdatesAsync(IPackage package, string version = "*")
{
await package.AddToIgnoredUpdatesAsync(version);
if (GetEquivalentPackage(package) is not { } upgradable)
return;

IgnoredPackages[upgradable.Id] = upgradable;
Remove(upgradable);
}

protected override async Task<bool> IsPackageValid(IPackage package)
{
if (package.VersionString == package.NewVersionString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,8 @@ OperationType operation
) => null;

public string? GetReinstallRefusal(IPackage package, InstallOptions options) => null;

public bool UpdateWasRefusedByPublisher(IReadOnlyList<string> processOutput, int returnCode) =>
false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,7 @@ OperationType operation
) => null;

public virtual string? GetReinstallRefusal(IPackage package, InstallOptions options) => null;

public virtual bool UpdateWasRefusedByPublisher(IReadOnlyList<string> processOutput, int returnCode) =>
false;
}
47 changes: 47 additions & 0 deletions src/UniGetUI.PackageEngine.Tests/UpgradablePackagesLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,53 @@ await installedLoader.AddForeign(
Assert.False(await loader.EvaluatePackageAsync(supersededPackage));
}

[Fact]
public async Task IgnoreUpdatesAsync_RemovesTheListedUpdateWhenGivenAnotherInstanceOfIt()
{
var manager = new PackageManagerBuilder().Build();
_ = new InstalledPackagesLoader([manager]);
_ = new DiscoverablePackagesLoader([manager]);
var loader = new TestUpgradablePackagesLoader([manager]);
var listed = new PackageBuilder()
.WithManager(manager)
.WithId("Contoso.Tool")
.WithVersion("1.0.0")
.WithNewVersion("2.0.0")
.Build();
var installed = new PackageBuilder()
.WithManager(manager)
.WithId("Contoso.Tool")
.WithVersion("1.0.0")
.Build();
await loader.AddForeign(listed);

await loader.IgnoreUpdatesAsync(installed);

Assert.False(loader.Contains(listed));
Assert.Same(listed, loader.IgnoredPackages["Contoso.Tool"]);
Assert.True(await listed.HasUpdatesIgnoredAsync());
}

[Fact]
public async Task IgnoreUpdatesAsync_RecordsTheRuleEvenWhenNoUpdateIsListed()
{
var manager = new PackageManagerBuilder().Build();
_ = new InstalledPackagesLoader([manager]);
_ = new DiscoverablePackagesLoader([manager]);
var loader = new TestUpgradablePackagesLoader([manager]);
var installed = new PackageBuilder()
.WithManager(manager)
.WithId("Contoso.Tool")
.WithVersion("1.0.0")
.Build();

await loader.IgnoreUpdatesAsync(installed, "2.0.0");

Assert.Empty(loader.IgnoredPackages);
Assert.True(await installed.HasUpdatesIgnoredAsync("2.0.0"));
Assert.False(await installed.HasUpdatesIgnoredAsync("3.0.0"));
}

// Regression test for issue #5293: the installed version carried a Homebrew build revision
// ("18.4_1"), which the version parser read as 18.41. That compared as greater than the
// available 18.6, so the loader discarded the update and it never reached the UI.
Expand Down
Loading
Loading