using System.Security.Cryptography; using EasyCompressor; using Млаумчерб.Клиент.классы; using static Млаумчерб.Клиент.сеть.Сеть; namespace Млаумчерб.Клиент.сеть.NetworkTaskFactories; public class JavaDownloadTaskFactory : INetworkTaskFactory { private const string INDEX_URL = "https://launchermeta.mojang.com/v1/products/java-runtime/2ec0cc96c44e5a76b9c8b7c39df7210883d12871/all.json"; private GameVersionDescriptor _descriptor; private IOPath _javaVersionDir; private SHA1 _hasher; private LZMACompressor _lzma; public JavaDownloadTaskFactory(GameVersionDescriptor descriptor) { _descriptor = descriptor; _javaVersionDir = Пути.GetJavaRuntimeDir(_descriptor.javaVersion.component); _hasher = SHA1.Create(); _lzma = new LZMACompressor(); } public Task CreateAsync(bool checkHashes) { NetworkTask? networkTask = null; if (!CheckFiles(checkHashes)) networkTask = new( $"java runtime '{_descriptor.javaVersion.component}'", GetTotalSize(), Download ); return Task.FromResult(networkTask); } private bool CheckFiles(bool checkHashes) { //TODO: download catalog //TODO: download manifest for required runtime //TODO: check whether files from manifest exist and match hashes throw new NotImplementedException(); } private long GetTotalSize() { //TODO: sum up size of all files invalidated by CheckFiles throw new NotImplementedException(); } private Task Download(NetworkProgressReporter pr, CancellationToken ct) { //TODO: download files using lzma decompression throw new NotImplementedException(); } }