Skip to content

Commit fb2f623

Browse files
martesiGabrielDufgithub-actions[bot]
authored
fix(classic): backport WinGet stuck and phantom update fixes
* Classic: stage PR 5167 backport * Fix WinGet update loop for packages whose upgrade never sticks (Devolutions#5167) (cherry picked from commit 4ca6074) * Classic: stage PR 5199 backport * Classic: retrigger PR 5199 staging workflow * Classic: stage PR 5199 with registered backport runner * Classic: adapt PR 5199 with prerequisite 4998 * Classic: make WinGet semantic backport anchors literal * Classic: use structural WinGet backport adapter * Classic: align WinGet regression fixtures with upstream * Classic: backport WinGet not-applicable and phantom-update fixes Semantically ports upstream 249cc4d (Devolutions#4998) and 26c93b8 (Devolutions#5199) on top of the Classic WinUI backend. * Classic: remove temporary WinGet backport runner * Classic: remove temporary PR 5199 runner * Classic: update backport ledger through PR 5199 --------- Co-authored-by: Gabriel Dufresne <78387669+GabrielDuf@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent e210c2c commit fb2f623

10 files changed

Lines changed: 386 additions & 54 deletions

File tree

‎maintenance/backports.yml‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,42 @@ upstream_base:
55
backports:
66
- commit: 21116375c8299d1db38a3c3b4c2eb7e18bc97c4e
77
upstream_pr: 5072
8-
status: candidate
8+
status: applied
99
class: backend
1010
reason: WinGet already-upgraded cache fix; package-engine only plus tests.
1111

1212
- commit: 905bcd14ab6ac7ffa4e712889c7c34c12f30309f
1313
upstream_pr: 5173
14-
status: candidate
14+
status: applied-semantic
1515
class: backend-shared-model
16-
reason: Honors explicit per-package install location on WinGet update.
16+
reason: Honors explicit per-package install location on WinGet update; adapted to Classic's inline location logic.
1717

1818
- commit: c0ddaa670523bd69fa5a036b3c18b2e96fb9c665
1919
upstream_pr: 5169
20-
status: candidate
20+
status: applied
2121
class: backend
2222
reason: Preserves PowerShell module scope during update discovery.
2323

2424
- commit: 4ca6074f301ffb5ea9b2ceb39bd87b814c1a973d
2525
upstream_pr: 5167
26-
status: partial
26+
status: applied-backend
2727
class: backend-plus-ui
28-
reason: Backport stuck-upgrade detection/settings storage first; port Classic settings UI separately. Required before PR 5199.
28+
reason: Stuck-upgrade detection, settings storage, language, and backend behavior are applied; the Avalonia settings control is intentionally excluded from Classic. Classic currently uses the backend default threshold of 3.
29+
30+
- commit: 249cc4d0d4c947dbe03b998ff392933f8aab15b6
31+
upstream_pr: 4998
32+
status: applied-semantic
33+
class: backend
34+
reason: Retries WinGet/Pinget updates reported as not applicable once without forced scope/architecture, then reports a real failure instead of faking success.
2935

3036
- commit: 26c93b859babdc831b2d8462048d3e5f85d3da67
3137
upstream_pr: 5199
32-
status: blocked-by-5167
38+
status: applied-semantic
3339
class: backend
3440
depends_on:
3541
- 4ca6074f301ffb5ea9b2ceb39bd87b814c1a973d
36-
reason: Suppresses non-applicable WinGet phantom updates using the stuck-upgrade machinery introduced by PR 5167.
42+
- 249cc4d0d4c947dbe03b998ff392933f8aab15b6
43+
reason: Suppresses non-applicable WinGet COM phantom updates using stuck-upgrade tracking after the relaxed not-applicable retry path has been exhausted.
3744

3845
- commit: fce15a3b10e630b269ce6e59be3c6522e3b0ea94
3946
upstream_pr: 5114

‎src/Languages/lang_en.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@
542542
"Reset WinGet": "Reset WinGet",
543543
"This may help if no packages are listed": "This may help if no packages are listed",
544544
"Force install location parameter when updating packages with custom locations": "Force install location parameter when updating packages with custom locations",
545+
"Stop offering an update that never applies after this many attempts": "Stop offering an update that never applies after this many attempts",
546+
"When WinGet keeps offering an update that reports success without ever changing the installed version, stop offering it after this many attempts, until a newer version is available (default: 3)": "When WinGet keeps offering an update that reports success without ever changing the installed version, stop offering it after this many attempts, until a newer version is available (default: 3)",
545547
"Install Scoop": "Install Scoop",
546548
"Uninstall Scoop (and its packages)": "Uninstall Scoop (and its packages)",
547549
"Run cleanup and clear cache": "Run cleanup and clear cache",

‎src/UniGetUI.Core.Settings/SettingsEngine_ImportExport.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ string entry in Directory.EnumerateFiles(CoreData.UniGetUIUserConfigurationDirec
3535
{
3636
"OperationHistory",
3737
"WinGetAlreadyUpgradedPackages.json",
38+
"WinGetUpgradeAttempts.json",
3839
"TelemetryClientToken",
3940
"CurrentSessionToken",
4041
}.Contains(Path.GetFileName(entry))
@@ -58,6 +59,7 @@ public static void ImportFromString_JSON(string jsonContent)
5859
{
5960
"OperationHistory",
6061
"WinGetAlreadyUpgradedPackages.json",
62+
"WinGetUpgradeAttempts.json",
6163
"TelemetryClientToken",
6264
"CurrentSessionToken",
6365
}.Contains(entry.Key)

‎src/UniGetUI.Core.Settings/SettingsEngine_Names.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public enum K
6161
DisabledManagers,
6262
DeletableDesktopShortcuts,
6363
WinGetAlreadyUpgradedPackages,
64+
WinGetUpgradeAttempts,
65+
WinGetStuckUpgradeThreshold,
6466
DependencyManagement,
6567
DisabledPackageManagerNotifications,
6668
PackageListViewMode,
@@ -169,6 +171,8 @@ public static string ResolveKey(K key)
169171
K.DisabledManagers => "DisabledManagers",
170172
K.DeletableDesktopShortcuts => "DeletableDesktopShortcuts",
171173
K.WinGetAlreadyUpgradedPackages => "WinGetAlreadyUpgradedPackages",
174+
K.WinGetUpgradeAttempts => "WinGetUpgradeAttempts",
175+
K.WinGetStuckUpgradeThreshold => "WinGetStuckUpgradeThreshold",
172176
K.DependencyManagement => "DependencyManagement",
173177
K.DisabledPackageManagerNotifications => "DisabledPackageManagerNotifications",
174178
K.PackageListViewMode => "PackageListViewMode",

‎src/UniGetUI.PackageEngine.Enums/OverridenInstallationOptions.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public struct OverridenInstallationOptions
77
public bool PowerShell_DoNotSetScopeParameter = false;
88
public bool? WinGet_SpecifyVersion = null;
99
public bool Pip_BreakSystemPackages = false;
10+
public bool WinGet_DropArchAndScope = false;
1011

1112
public OverridenInstallationOptions(string? scope = null, bool? runAsAdministrator = null)
1213
{
@@ -16,6 +17,6 @@ public OverridenInstallationOptions(string? scope = null, bool? runAsAdministrat
1617

1718
public override string ToString()
1819
{
19-
return $"<Scope={Scope};RunAsAdministrator={RunAsAdministrator};WG_SpecifyVersion={WinGet_SpecifyVersion};PS_NoScope={PowerShell_DoNotSetScopeParameter};Pip_BreakSystemPackages={Pip_BreakSystemPackages}>";
20+
return $"<Scope={Scope};RunAsAdministrator={RunAsAdministrator};WG_SpecifyVersion={WinGet_SpecifyVersion};PS_NoScope={PowerShell_DoNotSetScopeParameter};Pip_BreakSystemPackages={Pip_BreakSystemPackages};WG_DropArchAndScope={WinGet_DropArchAndScope}>";
2021
}
2122
}

‎src/UniGetUI.PackageEngine.Managers.WinGet/ClientHelpers/NativeWinGetHelper.cs‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,10 @@ public IReadOnlyList<Package> GetAvailableUpdates_UnSafe()
347347
nativePackage.DefaultInstallVersion.PackageCatalog.Info.Name
348348
);
349349

350-
string version = nativePackage.InstalledVersion.Version;
351-
if (version == "Unknown")
352-
version = WinGetPkgOperationHelper.GetLastInstalledVersion(nativePackage.Id);
350+
string version = WinGetPkgOperationHelper.ResolveReportedInstalledVersion(
351+
nativePackage.Id,
352+
nativePackage.InstalledVersion.Version
353+
);
353354

354355
var UniGetUIPackage = new Package(
355356
nativePackage.Name,
@@ -360,7 +361,11 @@ public IReadOnlyList<Package> GetAvailableUpdates_UnSafe()
360361
Manager
361362
);
362363

363-
// Trust COM IsUpdateAvailable, not the "already upgraded" cache (issue #5042).
364+
// Suppress an update that repeatedly fails to stick (#5158); the COM path still avoids
365+
// the one-shot "already upgraded" cache (#5042).
366+
if (WinGetPkgOperationHelper.IsStuckUpgradeLoop(UniGetUIPackage))
367+
continue;
368+
364369
NativePackageHandler.AddPackage(UniGetUIPackage, nativePackage);
365370
packages.Add(UniGetUIPackage);
366371
logger.Log(
@@ -409,9 +414,10 @@ public IReadOnlyList<Package> GetInstalledPackages_UnSafe()
409414
source = Manager.GetLocalSource(nativePackage.Id);
410415
}
411416

412-
string version = nativePackage.InstalledVersion.Version;
413-
if (version == "Unknown")
414-
version = WinGetPkgOperationHelper.GetLastInstalledVersion(nativePackage.Id);
417+
string version = WinGetPkgOperationHelper.ResolveReportedInstalledVersion(
418+
nativePackage.Id,
419+
nativePackage.InstalledVersion.Version
420+
);
415421

416422
logger.Log(
417423
$"Found package {nativePackage.Name} {nativePackage.Id} on source {source.Name}"

‎src/UniGetUI.PackageEngine.Managers.WinGet/ClientHelpers/PingetCliHelper.cs‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,29 @@ public IReadOnlyList<Package> GetAvailableUpdates_UnSafe()
4646
"upgrade --include-unknown --output json"
4747
);
4848

49+
return BuildUpdatePackages(result);
50+
}
51+
52+
internal IReadOnlyList<Package> BuildUpdatePackages(ListResponse result)
53+
{
4954
List<Package> packages = [];
5055
foreach (ListMatch match in result.Matches.Where(match => match.AvailableVersion is not null))
5156
{
57+
// Restore the version we last upgraded to when WinGet reports it as unknown (#5158).
58+
bool versionUnknown = WinGetPkgOperationHelper.IsUnknownVersion(match.InstalledVersion);
5259
var package = new Package(
5360
match.Name,
5461
match.Id,
55-
match.InstalledVersion,
62+
versionUnknown
63+
? WinGetPkgOperationHelper.GetLastInstalledVersion(match.Id)
64+
: match.InstalledVersion,
5665
match.AvailableVersion!,
5766
GetSource(match),
5867
Manager
5968
);
6069

61-
if (!WinGetPkgOperationHelper.ConsumeAlreadyUpgradedSuppression(package))
70+
// Skip one-shot suppression for unknown versions so the restored mark isn't cleared.
71+
if (versionUnknown || !WinGetPkgOperationHelper.ConsumeAlreadyUpgradedSuppression(package))
6272
{
6373
packages.Add(package);
6474
}
@@ -85,7 +95,7 @@ public IReadOnlyList<Package> GetInstalledPackages_UnSafe()
8595
new Package(
8696
match.Name,
8797
match.Id,
88-
match.InstalledVersion,
98+
WinGetPkgOperationHelper.ResolveReportedInstalledVersion(match.Id, match.InstalledVersion),
8999
GetSource(match),
90100
Manager
91101
)

‎src/UniGetUI.PackageEngine.Managers.WinGet/ClientHelpers/WinGetCliHelper.cs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,14 @@ public IReadOnlyList<Package> GetAvailableUpdates_UnSafe()
152152
source = Manager.SourcesHelper.Factory.GetSourceOrDefault(sourceName);
153153
}
154154

155+
// Restore the version we last upgraded to when WinGet reports it as unknown (#5158).
156+
bool versionUnknown = WinGetPkgOperationHelper.IsUnknownVersion(version);
157+
if (versionUnknown)
158+
version = WinGetPkgOperationHelper.GetLastInstalledVersion(id);
159+
155160
var package = new Package(name, id, version, newVersion, source, Manager);
156-
if (!WinGetPkgOperationHelper.ConsumeAlreadyUpgradedSuppression(package))
161+
// Skip one-shot suppression for unknown versions so the restored mark isn't cleared.
162+
if (versionUnknown || !WinGetPkgOperationHelper.ConsumeAlreadyUpgradedSuppression(package))
157163
{
158164
Packages.Add(package);
159165
}
@@ -290,6 +296,7 @@ public IReadOnlyList<Package> GetInstalledPackages_UnSafe()
290296
.Trim();
291297
source = Manager.SourcesHelper.Factory.GetSourceOrDefault(sourceName);
292298
}
299+
version = WinGetPkgOperationHelper.ResolveReportedInstalledVersion(id, version);
293300
Packages.Add(new Package(name, id, version, source, Manager));
294301
}
295302
OldLine = line;

0 commit comments

Comments
 (0)