Skip to content

Commit

Permalink
automatically disable same mods with different versions
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfds committed Dec 26, 2024
1 parent b695a42 commit e1e315f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Projektanker.Icons.Avalonia.MaterialDesign" Version="9.5.0" />
<PackageVersion Include="Projektanker.Icons.Avalonia.MaterialDesign" Version="9.6.0" />
<PackageVersion Include="Roslynator.Analyzers" Version="4.12.10" />
<PackageVersion Include="SharpCompress" Version="0.38.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="System.Private.Uri" Version="4.3.2" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />
<PackageVersion Include="AWSSDK.S3" Version="3.7.410.8" />
<PackageVersion Include="AWSSDK.S3" Version="3.7.410.11" />
<PackageVersion Include="ConfigureAwaitAnalyzer" Version="1.1.0" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="7.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.SpaProxy" Version="9.0.0" />
Expand Down
7 changes: 7 additions & 0 deletions src/Addons/Providers/InstalledAddonsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ public void EnableAddon(AddonVersion addon)
}
}

var otherVersions = _cache[AddonTypeEnum.Mod].Where(x => x.Key.Id == addon.Id && !VersionComparer.Compare(x.Key.Version, addon.Version, "=="));

foreach (var version in otherVersions)
{
DisableAddon(version.Key);
}

_config.ChangeModState(addon, true);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Common.Common/Helpers/VersionComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static bool Compare(string? v1, string v2)
return Compare(v1, v2, op);
}

public static bool Compare(string? v1, string v2, string op)
public static bool Compare(string? v1, string? v2, string op)
{
if (v1 is null)
{
Expand Down
9 changes: 9 additions & 0 deletions src/Tests/VersionCompareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ public void CompareTest2(string v1, string v2)

Assert.True(result);
}

[Theory]
[InlineData(null, null, "==")]
public void CompareTest3(string? v1, string? v2, string c)
{
var result = VersionComparer.Compare(v1, v2, c);

Assert.True(result);
}
}

0 comments on commit e1e315f

Please sign in to comment.