mlaumcherb/Mlaumcherb.Client.Avalonia/классы/Пролетариат/MyModpack.cs
2024-12-31 20:03:31 +05:00

49 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<string, FileProps> 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; }
}
public bool CheckFiles(IOPath basedir, bool checkHashes, bool downloadOptionalFiles, HashSet<IOPath> unmatchedFilesLocalPaths)
{
foreach (var p in files)
{
if(!downloadOptionalFiles && p.Value.optional)
continue;
var localPath = new IOPath(p.Key);
var realPath = Path.Concat(basedir, localPath);
if (!HashHelper.CheckFileSHA1(realPath, p.Value.sha1, checkHashes && !p.Value.allow_edit))
{
unmatchedFilesLocalPaths.Add(localPath);
}
}
return unmatchedFilesLocalPaths.Count == 0;
}
}