Browse Source

Added Semver version verification to ModsaberModInfo

pull/46/head
Anairkoen Schno 6 years ago
parent
commit
df913857e9
3 changed files with 15 additions and 8 deletions
  1. +3
    -1
      IPA.Loader/Loader/PluginManager.cs
  2. +6
    -0
      IPA.Loader/PluginInterfaces/BeatSaber/ModsaberModInfo.cs
  3. +6
    -7
      IPA.Loader/Updating/ModSaber/Updater.cs

+ 3
- 1
IPA.Loader/Loader/PluginManager.cs View File

@ -188,7 +188,9 @@ namespace IPA.Loader
_bsPlugins.Add(selfPlugin);
configProviders.Add(new KeyValuePair<IConfigProvider, Ref<DateTime>>(SelfConfigProvider = new JsonConfigProvider { Filename = Path.Combine("UserData", SelfPlugin.IPA_Name) }, new Ref<DateTime>(SelfConfigProvider.LastModified)));
configProviders.Add(new KeyValuePair<IConfigProvider, Ref<DateTime>>(
SelfConfigProvider = new JsonConfigProvider {Filename = Path.Combine("UserData", SelfPlugin.IPA_Name)},
new Ref<DateTime>(SelfConfigProvider.LastModified)));
SelfConfigProvider.Load();
//Load copied plugins


+ 6
- 0
IPA.Loader/PluginInterfaces/BeatSaber/ModsaberModInfo.cs View File

@ -1,4 +1,6 @@
using System;
using Version = SemVer.Version;
// ReSharper disable CheckNamespace
namespace IPA
@ -39,7 +41,9 @@ namespace IPA
{
if (_currentVersion == null)
{
var version = new Version(value); // check for valid version
_currentVersion = value;
_semverVersion = version;
}
else
{
@ -48,5 +52,7 @@ namespace IPA
}
}
private string _currentVersion;
internal Version _semverVersion = null;
}
}

+ 6
- 7
IPA.Loader/Updating/ModSaber/Updater.cs View File

@ -70,7 +70,7 @@ namespace IPA.Updating.ModSaber
}
}
private Dictionary<string, string> requestCache = new Dictionary<string, string>();
private readonly Dictionary<string, string> requestCache = new Dictionary<string, string>();
private IEnumerator GetModsaberEndpoint(string url, Ref<string> result)
{
if (requestCache.TryGetValue(url, out string value))
@ -174,7 +174,7 @@ namespace IPA.Updating.ModSaber
var msinfo = plugin.ModSaberInfo;
depList.Value.Add(new DependencyObject {
Name = msinfo.InternalName,
Version = new Version(msinfo.CurrentVersion),
Version = msinfo._semverVersion,
Requirement = new Range($">={msinfo.CurrentVersion}"),
LocalPluginMeta = plugin
});
@ -234,7 +234,7 @@ namespace IPA.Updating.ModSaber
}
else
{
var toMod = final.Where(d => d.Name == dep.Name).First();
var toMod = final.First(d => d.Name == dep.Name);
if (dep.Requirement != null)
{
@ -244,10 +244,9 @@ namespace IPA.Updating.ModSaber
}
else if (dep.Conflicts != null)
{
if (toMod.Conflicts == null)
toMod.Conflicts = dep.Conflicts;
else
toMod.Conflicts = new Range($"{toMod.Conflicts} || {dep.Conflicts}"); // there should be a better way to do this
toMod.Conflicts = toMod.Conflicts == null
? dep.Conflicts
: new Range($"{toMod.Conflicts} || {dep.Conflicts}");
}
}
}


Loading…
Cancel
Save