using Mlaumcherb.Client.Avalonia.холопы; namespace Mlaumcherb.Client.Avalonia.классы; public class MyModpackRemoteProps { [JsonRequired] public int format_version { get; set; } [JsonRequired] public Artifact artifact { get; set; } = null!; } public class MyModpackV1 { // 1 [JsonRequired] public int format_version { get; set; } [JsonRequired] public string name { get; set; } = ""; // zip archive with all files [JsonRequired] public Artifact zip { get; set; } = null!; /// relative_path, hash // ReSharper disable once CollectionNeverUpdated.Global [JsonRequired] public Dictionary files { get; set; } = new(); public class FileProps { [JsonRequired] public string sha1 { get; set; } = ""; // disable hash validation, allowing users to edit this file public bool allow_edit { get; set; } // don't re-download file if it was deleted by user public bool optional { get; set; } } /// relative, absolute public Dictionary CheckFiles(IOPath basedir, bool checkHashes, bool downloadOptionalFiles) { Dictionary unmatchedFiles = new(); IOPath launcherRoot = PathHelper.GetRootFullPath(); foreach (var p in files) { if(!downloadOptionalFiles && p.Value.optional) continue; IOPath relativePath = new IOPath(p.Key); var absolutePath = Path.Concat(relativePath.StartsWith("libraries") ? launcherRoot : basedir, relativePath); if (!HashHelper.CheckFileSHA1(absolutePath, p.Value.sha1, checkHashes && !p.Value.allow_edit)) { unmatchedFiles.Add(relativePath, absolutePath); } } return unmatchedFiles; } }