Browse Source

Actually fixed no-update

Now properly parses the dumb deep dependencies of BeatMods
pull/11/head
Anairkoen Schno 5 years ago
parent
commit
e06016f5ed
2 changed files with 56 additions and 16 deletions
  1. +22
    -1
      IPA.Loader/Updating/BeatMods/ApiEndpoint.cs
  2. +34
    -15
      IPA.Loader/Updating/BeatMods/Updater.cs

+ 22
- 1
IPA.Loader/Updating/BeatMods/ApiEndpoint.cs View File

@ -4,6 +4,7 @@ using System.Linq;
using IPA.JsonConverters;
using IPA.Utilities;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SemVer;
using Version = SemVer.Version;
@ -60,6 +61,23 @@ namespace IPA.Updating.BeatMods
}
}
}
class ModMultiformatJsonConverter : JsonConverter<Mod>
{
public override Mod ReadJson(JsonReader reader, Type objectType, Mod existingValue, bool hasExistingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.String)
return new Mod { Id = reader.Value as string, IsIdReference = true };
else
{
if (reader.TokenType != JsonToken.StartObject)
return null;
return serializer.Deserialize<Mod>(reader);
}
}
public override void WriteJson(JsonWriter writer, Mod value, JsonSerializer serializer) => serializer.Serialize(writer, value);
}
[Serializable]
public class Mod
@ -71,6 +89,9 @@ namespace IPA.Updating.BeatMods
[JsonProperty("_id")]
public string Id;
[JsonIgnore]
public bool IsIdReference = false;
[JsonProperty("required")]
public bool Required;
@ -210,7 +231,7 @@ namespace IPA.Updating.BeatMods
[JsonProperty("oldVersions", ItemConverterType = typeof(SemverVersionConverter))]
public Version[] OldVersions = new Version[0];*/
[JsonProperty("dependencies")]
[JsonProperty("dependencies", ItemConverterType = typeof(ModMultiformatJsonConverter))]
public Mod[] Dependencies;
public override string ToString()


+ 34
- 15
IPA.Loader/Updating/BeatMods/Updater.cs View File

@ -170,34 +170,53 @@ namespace IPA.Updating.BeatMods
{
var depList = new Ref<List<DependencyObject>>(new List<DependencyObject>());
foreach (var plugin in BSMetas
.Where(m => m.Metadata.Features.FirstOrDefault(f => f is NoUpdateFeature) != null))
foreach (var plugin in BSMetas)
//.Where(m => m.Metadata.Features.FirstOrDefault(f => f is NoUpdateFeature) == null))
{ // initialize with data to resolve (1.1)
if (plugin.Metadata.Id != null)
{ // updatable
var msinfo = plugin.Metadata;
depList.Value.Add(new DependencyObject {
var dep = new DependencyObject
{
Name = msinfo.Id,
Version = msinfo.Version,
Requirement = new Range($">{msinfo.Version}"),
Requirement = new Range($">={msinfo.Version}"),
LocalPluginMeta = plugin
});
};
if (msinfo.Features.FirstOrDefault(f => f is NoUpdateFeature) != null)
{ // disable updating, by only matching self, so that dependencies can still be resolved
dep.Requirement = new Range(msinfo.Version.ToString());
}
depList.Value.Add(dep);
}
}
foreach (var meta in PluginLoader.ignoredPlugins.Where(m => m.Id != null)
.Where(m => m.Features.FirstOrDefault(f => f is NoUpdateFeature) != null))
foreach (var meta in PluginLoader.ignoredPlugins.Where(m => m.Id != null))
//.Where(m => m.Features.FirstOrDefault(f => f is NoUpdateFeature) == null))
{
depList.Value.Add(new DependencyObject
{
Name = meta.Id,
Version = meta.Version,
Requirement = new Range($">{meta.Version}"),
LocalPluginMeta = new PluginLoader.PluginInfo
if (meta.Id != null)
{ // updatable
var dep = new DependencyObject
{
Metadata = meta, Plugin = null
Name = meta.Id,
Version = meta.Version,
Requirement = new Range($">={meta.Version}"),
LocalPluginMeta = new PluginLoader.PluginInfo
{
Metadata = meta,
Plugin = null
}
};
if (meta.Features.FirstOrDefault(f => f is NoUpdateFeature) != null)
{ // disable updating, by only matching self
dep.Requirement = new Range(meta.Version.ToString());
}
});
depList.Value.Add(dep);
}
}
foreach (var dep in depList.Value)


Loading…
Cancel
Save