Skip to content

Commit f411842

Browse files
committed
Improvements to WinGet's package update blacklisting logic (fix #2929)
1 parent 0155734 commit f411842

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/UniGetUI.PackageEngine.Managers.WinGet/Helpers/WinGetPkgOperationHelper.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using UniGetUI.PackageEngine.Classes.Packages.Classes;
77
using UniGetUI.PackageEngine.Enums;
88
using UniGetUI.PackageEngine.Interfaces;
9+
using UniGetUI.PackageEngine.PackageClasses;
910
using Architecture = UniGetUI.PackageEngine.Enums.Architecture;
1011
using InstallOptions = UniGetUI.PackageEngine.Serializable.InstallOptions;
1112

@@ -147,7 +148,7 @@ protected override OperationVeredict _getOperationResult(
147148

148149
if (uintCode is 0x8A150109)
149150
{ // TODO: Restart required to finish installation
150-
if (operation is OperationType.Update) MarkUpgradeAsDone(package);
151+
if (operation is OperationType.Update or OperationType.Install) MarkUpgradeAsDone(package);
151152
return OperationVeredict.Success;
152153
}
153154

@@ -180,13 +181,13 @@ protected override OperationVeredict _getOperationResult(
180181

181182
if (uintCode is 0x8A15010D or 0x8A15004F or 0x8A15010E)
182183
{ // Application is already installed
183-
if (operation is OperationType.Update) MarkUpgradeAsDone(package);
184+
if (operation is OperationType.Update or OperationType.Install) MarkUpgradeAsDone(package);
184185
return OperationVeredict.Success;
185186
}
186187

187188
if (returnCode is 0)
188189
{ // Operation succeeded
189-
if (operation is OperationType.Update) MarkUpgradeAsDone(package);
190+
if (operation is OperationType.Update or OperationType.Install) MarkUpgradeAsDone(package);
190191
return OperationVeredict.Success;
191192
}
192193

@@ -214,7 +215,12 @@ protected override OperationVeredict _getOperationResult(
214215

215216
private static void MarkUpgradeAsDone(IPackage package)
216217
{
217-
Settings.SetDictionaryItem<string, string>(Settings.K.WinGetAlreadyUpgradedPackages, package.Id, package.NewVersionString);
218+
var options = InstallOptionsFactory.LoadApplicable(package);
219+
string version;
220+
if (package.IsUpgradable) version = package.NewVersionString;
221+
else if (options.Version != "") version = options.Version;
222+
else version = package.VersionString;
223+
Settings.SetDictionaryItem<string, string>(Settings.K.WinGetAlreadyUpgradedPackages, package.Id, version);
218224
}
219225

220226
public static bool UpdateAlreadyInstalled(IPackage package)

0 commit comments

Comments
 (0)