mlaumcherb/Млаумчерб.Клиент/сеть/NetworkTaskFactories/JavaDownloadTaskFactory.cs
2024-10-18 18:13:22 +05:00

56 lines
1.9 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 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<NetworkTask?> 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();
}
}