Skip to content

Commit f7a3c2f

Browse files
authored
Merge pull request #3827 from theguy000/feat/recheck-version-before-update
2 parents d26be95 + 5ad3cc4 commit f7a3c2f

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/UniGetUI.PackageEngine.Operations/PackageOperations.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ public UpdatePackageOperation(
242242
bool IgnoreParallelInstalls = false,
243243
AbstractOperation? req = null)
244244
: base(package, options, OperationType.Update, IgnoreParallelInstalls, req)
245-
{ }
245+
{
246+
}
246247

247248
protected override Task HandleFailure()
248249
{

src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Classes/PackageCacher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static bool NewerVersionIsInstalled(Package other)
102102
{
103103
foreach (Package found in __installed_pkgs.Values)
104104
{
105-
if (found.IsEquivalentTo(other) && found.NormalizedVersion == other.NormalizedNewVersion)
105+
if (found.IsEquivalentTo(other) && found.NormalizedVersion >= other.NormalizedNewVersion)
106106
{
107107
return true;
108108
}

src/UniGetUI/AppOperationHelper.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,17 @@ public static void Install(IReadOnlyList<IPackage> packages, TEL_InstallReferral
193193
public static async Task<AbstractOperation?> Update(IPackage? package, bool? elevated = null, bool? interactive = null, bool? no_integrity = null, bool ignoreParallel = false, AbstractOperation? req = null)
194194
{
195195
if (package is null) return null;
196+
if (package.NewerVersionIsInstalled())
197+
{
198+
Logger.Warn($"A newer version of {package.Id} has been detected, the update will not be performed!");
199+
PEInterface.UpgradablePackagesLoader.Remove(package);
200+
foreach (var eq in PEInterface.InstalledPackagesLoader.GetEquivalentPackages(package))
201+
{ // Remove upgradable tag from all installed packages
202+
eq.Tag = PackageTag.Default;
203+
}
204+
205+
return null;
206+
}
196207

197208
var options = await InstallOptionsFactory.LoadApplicableAsync(package, elevated, interactive, no_integrity);
198209
var operation = new UpdatePackageOperation(package, options, ignoreParallel, req);

0 commit comments

Comments
 (0)