Compare commits
2 Commits
4704f1217a
...
ae7e5096fc
| Author | SHA1 | Date | |
|---|---|---|---|
| ae7e5096fc | |||
| beb701ca40 |
@ -16,7 +16,7 @@ public class GameVersion
|
|||||||
|
|
||||||
private IOPath JavaExecutableFilePath;
|
private IOPath JavaExecutableFilePath;
|
||||||
|
|
||||||
private VersionDescriptor descriptor;
|
private GameVersionDescriptor descriptor;
|
||||||
private JavaArguments javaArgs;
|
private JavaArguments javaArgs;
|
||||||
private GameArguments gameArgs;
|
private GameArguments gameArgs;
|
||||||
private Libraries libraries;
|
private Libraries libraries;
|
||||||
@ -54,7 +54,7 @@ public class GameVersion
|
|||||||
{
|
{
|
||||||
_props = props;
|
_props = props;
|
||||||
string descriptorText = File.ReadAllText(props.LocalDescriptorPath);
|
string descriptorText = File.ReadAllText(props.LocalDescriptorPath);
|
||||||
descriptor = JsonConvert.DeserializeObject<VersionDescriptor>(descriptorText)
|
descriptor = JsonConvert.DeserializeObject<GameVersionDescriptor>(descriptorText)
|
||||||
?? throw new Exception($"can't parse descriptor file '{props.LocalDescriptorPath}'");
|
?? throw new Exception($"can't parse descriptor file '{props.LocalDescriptorPath}'");
|
||||||
javaArgs = new JavaArguments(descriptor);
|
javaArgs = new JavaArguments(descriptor);
|
||||||
gameArgs = new GameArguments(descriptor);
|
gameArgs = new GameArguments(descriptor);
|
||||||
|
|||||||
@ -22,9 +22,10 @@
|
|||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.*" />
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.*" />
|
||||||
<PackageReference Include="Avalonia.Labs.Gif" Version="11.2.999-cibuild-00051673"/>
|
<PackageReference Include="Avalonia.Labs.Gif" Version="11.2.999-cibuild-00051673"/>
|
||||||
<PackageReference Include="CliWrap" Version="3.6.*" />
|
<PackageReference Include="CliWrap" Version="3.6.*" />
|
||||||
<PackageReference Include="DTLib" Version="1.4.2" />
|
<PackageReference Include="DTLib" Version="1.4.3" />
|
||||||
<PackageReference Include="MessageBox.Avalonia" Version="3.1.*" />
|
<PackageReference Include="MessageBox.Avalonia" Version="3.1.*" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.*" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.*" />
|
||||||
|
<PackageReference Include="EasyCompressor.LZMA" Version="2.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -9,7 +9,7 @@ public class GameArguments : ArgumentsWithPlaceholders
|
|||||||
"has_custom_resolution"
|
"has_custom_resolution"
|
||||||
];
|
];
|
||||||
|
|
||||||
public GameArguments(VersionDescriptor d)
|
public GameArguments(GameVersionDescriptor d)
|
||||||
{
|
{
|
||||||
if (d.minecraftArguments is not null)
|
if (d.minecraftArguments is not null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
namespace Млаумчерб.Клиент.классы;
|
namespace Млаумчерб.Клиент.классы;
|
||||||
|
|
||||||
public class VersionCatalog
|
public class GameVersionCatalog
|
||||||
{
|
{
|
||||||
[JsonRequired] public List<RemoteVersionDescriptorProps> versions { get; set; } = null!;
|
[JsonRequired] public List<RemoteVersionDescriptorProps> versions { get; set; } = null!;
|
||||||
}
|
}
|
||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
namespace Млаумчерб.Клиент.классы;
|
namespace Млаумчерб.Клиент.классы;
|
||||||
|
|
||||||
public class VersionDescriptor
|
public class GameVersionDescriptor
|
||||||
{
|
{
|
||||||
[JsonRequired] public string id { get; set; } = "";
|
[JsonRequired] public string id { get; set; } = "";
|
||||||
[JsonRequired] public DateTime time { get; set; }
|
[JsonRequired] public DateTime time { get; set; }
|
||||||
@ -12,7 +12,7 @@ public class JavaArguments : ArgumentsWithPlaceholders
|
|||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public JavaArguments(VersionDescriptor d)
|
public JavaArguments(GameVersionDescriptor d)
|
||||||
{
|
{
|
||||||
raw_args.AddRange(_initial_arguments);
|
raw_args.AddRange(_initial_arguments);
|
||||||
if (d.arguments is not null)
|
if (d.arguments is not null)
|
||||||
|
|||||||
30
Млаумчерб.Клиент/классы/JavaVersionCatalog.cs
Normal file
30
Млаумчерб.Клиент/классы/JavaVersionCatalog.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
namespace Млаумчерб.Клиент.классы;
|
||||||
|
|
||||||
|
public class JavaVersionCatalog
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JavaVersionProps
|
||||||
|
{
|
||||||
|
[JsonRequired] public Artifact manifest { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JavaVersionManifest
|
||||||
|
{
|
||||||
|
[JsonRequired] public Dictionary<string, JavaDistributiveElementProps> manifest { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JavaDistributiveElementProps
|
||||||
|
{
|
||||||
|
// "directory" / "file"
|
||||||
|
[JsonRequired] public string type { get; set; } = "";
|
||||||
|
public bool? executable { get; set; }
|
||||||
|
public JavaCompressedArtifact? downloads { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JavaCompressedArtifact
|
||||||
|
{
|
||||||
|
public Artifact? lzma { get; set; }
|
||||||
|
public Artifact raw { get; set; } = null!;
|
||||||
|
}
|
||||||
@ -7,12 +7,12 @@ public class Libraries
|
|||||||
private static readonly string[] enabled_features = [];
|
private static readonly string[] enabled_features = [];
|
||||||
|
|
||||||
public record JarLib(string name, IOPath jarFilePath, Artifact artifact);
|
public record JarLib(string name, IOPath jarFilePath, Artifact artifact);
|
||||||
public record NativeLib(string name, IOPath jarFilePath, Artifact artifact, IOPath nativeFilesDir, Extract? extractionOptions)
|
public record NativeLib(string name, IOPath jarFilePath, Artifact artifact, Extract? extractionOptions)
|
||||||
: JarLib(name, jarFilePath, artifact);
|
: JarLib(name, jarFilePath, artifact);
|
||||||
|
|
||||||
public IReadOnlyCollection<JarLib> Libs { get; }
|
public IReadOnlyCollection<JarLib> Libs { get; }
|
||||||
|
|
||||||
public Libraries(VersionDescriptor descriptor)
|
public Libraries(GameVersionDescriptor descriptor)
|
||||||
{
|
{
|
||||||
List<JarLib> libs = new();
|
List<JarLib> libs = new();
|
||||||
HashSet<string> libHashes = new();
|
HashSet<string> libHashes = new();
|
||||||
@ -43,9 +43,9 @@ public class Libraries
|
|||||||
if(!libHashes.Add(artifact.sha1))
|
if(!libHashes.Add(artifact.sha1))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IOPath dir = Пути.GetVersionDir(descriptor.id);
|
string urlTail = artifact.url.AsSpan().After("://").After('/').ToString();
|
||||||
IOPath jarPath = Path.Concat(dir, Path.ReplaceRestrictedChars(l.name));
|
IOPath jarFilePath = Path.Concat(Пути.GetLibrariesDir(), urlTail);
|
||||||
libs.Add(new NativeLib(l.name, jarPath, artifact, dir, l.extract));
|
libs.Add(new NativeLib(l.name, jarFilePath, artifact, l.extract));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -57,8 +57,9 @@ public class Libraries
|
|||||||
if(!libHashes.Add(artifact.sha1))
|
if(!libHashes.Add(artifact.sha1))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IOPath path = artifact.url.AsSpan().After("://").After('/').ToString();
|
string urlTail = artifact.url.AsSpan().After("://").After('/').ToString();
|
||||||
libs.Add(new JarLib(l.name, Path.Concat(Пути.GetLibrariesDir(), path), artifact));
|
IOPath jarFilePath = Path.Concat(Пути.GetLibrariesDir(), urlTail);
|
||||||
|
libs.Add(new JarLib(l.name, jarFilePath, artifact));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,4 +53,13 @@ public static class Буржуазия
|
|||||||
|
|
||||||
return allowed;
|
return allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetOs() =>
|
||||||
|
Environment.OSVersion.Platform switch
|
||||||
|
{
|
||||||
|
PlatformID.Win32NT => "windows",
|
||||||
|
PlatformID.Unix => "linux",
|
||||||
|
PlatformID.MacOSX => "osx",
|
||||||
|
_ => throw new ArgumentOutOfRangeException(Environment.OSVersion.Platform.ToString())
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,9 @@ public static class Пути
|
|||||||
public static IOPath GetLibrariesDir() =>
|
public static IOPath GetLibrariesDir() =>
|
||||||
Path.Concat(Приложение.Настройки.путь_к_кубачу, "libraries");
|
Path.Concat(Приложение.Настройки.путь_к_кубачу, "libraries");
|
||||||
|
|
||||||
|
public static IOPath GetNativeLibrariesDir(string id) =>
|
||||||
|
Path.Concat(GetVersionDir(id), "natives", Буржуазия.GetOs());
|
||||||
|
|
||||||
public static IOPath GetJavaRuntimesDir() =>
|
public static IOPath GetJavaRuntimesDir() =>
|
||||||
Path.Concat(Приложение.Настройки.путь_к_кубачу, "java");
|
Path.Concat(Приложение.Настройки.путь_к_кубачу, "java");
|
||||||
|
|
||||||
|
|||||||
@ -9,12 +9,12 @@ namespace Млаумчерб.Клиент.сеть.NetworkTaskFactories;
|
|||||||
public class AssetsDownloadTaskFactory : INetworkTaskFactory
|
public class AssetsDownloadTaskFactory : INetworkTaskFactory
|
||||||
{
|
{
|
||||||
private const string ASSET_SERVER_URL = "https://resources.download.minecraft.net/";
|
private const string ASSET_SERVER_URL = "https://resources.download.minecraft.net/";
|
||||||
private VersionDescriptor _descriptor;
|
private GameVersionDescriptor _descriptor;
|
||||||
private SHA1 _hasher;
|
private SHA1 _hasher;
|
||||||
private IOPath _indexFilePath;
|
private IOPath _indexFilePath;
|
||||||
List<AssetDownloadProperties> _assetsToDownload = new();
|
List<AssetDownloadProperties> _assetsToDownload = new();
|
||||||
|
|
||||||
public AssetsDownloadTaskFactory(VersionDescriptor descriptor)
|
public AssetsDownloadTaskFactory(GameVersionDescriptor descriptor)
|
||||||
{
|
{
|
||||||
_descriptor = descriptor;
|
_descriptor = descriptor;
|
||||||
_hasher = SHA1.Create();
|
_hasher = SHA1.Create();
|
||||||
@ -86,7 +86,7 @@ public class AssetsDownloadTaskFactory : INetworkTaskFactory
|
|||||||
public string url;
|
public string url;
|
||||||
public IOPath filePath;
|
public IOPath filePath;
|
||||||
|
|
||||||
public AssetDownloadProperties(string key, AssetProperties p)
|
public AssetDownloadProperties(string key, GameAssetProperties p)
|
||||||
{
|
{
|
||||||
name = key;
|
name = key;
|
||||||
hash = p.hash;
|
hash = p.hash;
|
||||||
@ -99,7 +99,7 @@ public class AssetsDownloadTaskFactory : INetworkTaskFactory
|
|||||||
|
|
||||||
private async Task Download(NetworkProgressReporter pr, CancellationToken ct)
|
private async Task Download(NetworkProgressReporter pr, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Приложение.Логгер.LogInfo(nameof(Сеть), "started downloading assets");
|
Приложение.Логгер.LogInfo(nameof(Сеть), $"started downloading assets '{_descriptor.assetIndex.id}'");
|
||||||
ParallelOptions opt = new() { MaxDegreeOfParallelism = ParallelDownloadsN, CancellationToken = ct };
|
ParallelOptions opt = new() { MaxDegreeOfParallelism = ParallelDownloadsN, CancellationToken = ct };
|
||||||
await Parallel.ForEachAsync(_assetsToDownload, opt,
|
await Parallel.ForEachAsync(_assetsToDownload, opt,
|
||||||
async (a, _ct) =>
|
async (a, _ct) =>
|
||||||
@ -107,6 +107,6 @@ public class AssetsDownloadTaskFactory : INetworkTaskFactory
|
|||||||
Приложение.Логгер.LogDebug(nameof(Сеть), $"downloading asset '{a.name}' {a.hash}");
|
Приложение.Логгер.LogDebug(nameof(Сеть), $"downloading asset '{a.name}' {a.hash}");
|
||||||
await DownloadFileHTTP(a.url, a.filePath, _ct, pr.AddBytesCount);
|
await DownloadFileHTTP(a.url, a.filePath, _ct, pr.AddBytesCount);
|
||||||
});
|
});
|
||||||
Приложение.Логгер.LogInfo(nameof(Сеть), "finished downloading assets");
|
Приложение.Логгер.LogInfo(nameof(Сеть), $"finished downloading assets '{_descriptor.assetIndex.id}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
using EasyCompressor;
|
||||||
using Млаумчерб.Клиент.классы;
|
using Млаумчерб.Клиент.классы;
|
||||||
using static Млаумчерб.Клиент.сеть.Сеть;
|
using static Млаумчерб.Клиент.сеть.Сеть;
|
||||||
|
|
||||||
@ -6,15 +7,19 @@ namespace Млаумчерб.Клиент.сеть.NetworkTaskFactories;
|
|||||||
|
|
||||||
public class JavaDownloadTaskFactory : INetworkTaskFactory
|
public class JavaDownloadTaskFactory : INetworkTaskFactory
|
||||||
{
|
{
|
||||||
private VersionDescriptor _descriptor;
|
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 SHA1 _hasher;
|
||||||
IOPath _javaVersionDir;
|
private LZMACompressor _lzma;
|
||||||
|
|
||||||
public JavaDownloadTaskFactory(VersionDescriptor descriptor)
|
public JavaDownloadTaskFactory(GameVersionDescriptor descriptor)
|
||||||
{
|
{
|
||||||
_descriptor = descriptor;
|
_descriptor = descriptor;
|
||||||
_hasher = SHA1.Create();
|
|
||||||
_javaVersionDir = Пути.GetJavaRuntimeDir(_descriptor.javaVersion.component);
|
_javaVersionDir = Пути.GetJavaRuntimeDir(_descriptor.javaVersion.component);
|
||||||
|
_hasher = SHA1.Create();
|
||||||
|
_lzma = new LZMACompressor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<NetworkTask?> CreateAsync(bool checkHashes)
|
public Task<NetworkTask?> CreateAsync(bool checkHashes)
|
||||||
@ -31,16 +36,21 @@ public class JavaDownloadTaskFactory : INetworkTaskFactory
|
|||||||
|
|
||||||
private bool CheckFiles(bool checkHashes)
|
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();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private long GetTotalSize()
|
private long GetTotalSize()
|
||||||
{
|
{
|
||||||
|
//TODO: sum up size of all files invalidated by CheckFiles
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task Download(NetworkProgressReporter pr, CancellationToken ct)
|
private Task Download(NetworkProgressReporter pr, CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
//TODO: download files using lzma decompression
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Security.Cryptography;
|
using System.IO.Compression;
|
||||||
|
using System.Security.Cryptography;
|
||||||
using DTLib.Extensions;
|
using DTLib.Extensions;
|
||||||
using Млаумчерб.Клиент.видимое;
|
using Млаумчерб.Клиент.видимое;
|
||||||
using Млаумчерб.Клиент.классы;
|
using Млаумчерб.Клиент.классы;
|
||||||
@ -8,16 +9,18 @@ namespace Млаумчерб.Клиент.сеть.NetworkTaskFactories;
|
|||||||
|
|
||||||
public class LibrariesDownloadTaskFactory : INetworkTaskFactory
|
public class LibrariesDownloadTaskFactory : INetworkTaskFactory
|
||||||
{
|
{
|
||||||
private VersionDescriptor _descriptor;
|
private GameVersionDescriptor _descriptor;
|
||||||
private Libraries _libraries;
|
private Libraries _libraries;
|
||||||
private SHA1 _hasher;
|
private SHA1 _hasher;
|
||||||
private List<Libraries.JarLib> _libsToDownload = new();
|
private List<Libraries.JarLib> _libsToDownload = new();
|
||||||
|
private IOPath _nativesDir;
|
||||||
|
|
||||||
public LibrariesDownloadTaskFactory(VersionDescriptor descriptor, Libraries libraries)
|
public LibrariesDownloadTaskFactory(GameVersionDescriptor descriptor, Libraries libraries)
|
||||||
{
|
{
|
||||||
_descriptor = descriptor;
|
_descriptor = descriptor;
|
||||||
_libraries = libraries;
|
_libraries = libraries;
|
||||||
_hasher = SHA1.Create();
|
_hasher = SHA1.Create();
|
||||||
|
_nativesDir = Пути.GetNativeLibrariesDir(descriptor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<NetworkTask?> CreateAsync(bool checkHashes)
|
public Task<NetworkTask?> CreateAsync(bool checkHashes)
|
||||||
@ -35,6 +38,7 @@ public class LibrariesDownloadTaskFactory : INetworkTaskFactory
|
|||||||
private bool CheckFiles(bool checkHashes)
|
private bool CheckFiles(bool checkHashes)
|
||||||
{
|
{
|
||||||
_libsToDownload.Clear();
|
_libsToDownload.Clear();
|
||||||
|
bool nativeDirExists = Directory.Exists(_nativesDir);
|
||||||
|
|
||||||
foreach (var l in _libraries.Libs)
|
foreach (var l in _libraries.Libs)
|
||||||
{
|
{
|
||||||
@ -42,6 +46,10 @@ public class LibrariesDownloadTaskFactory : INetworkTaskFactory
|
|||||||
{
|
{
|
||||||
_libsToDownload.Add(l);
|
_libsToDownload.Add(l);
|
||||||
}
|
}
|
||||||
|
else if (!nativeDirExists && l is Libraries.NativeLib)
|
||||||
|
{
|
||||||
|
_libsToDownload.Add(l);
|
||||||
|
}
|
||||||
else if (checkHashes)
|
else if (checkHashes)
|
||||||
{
|
{
|
||||||
using var fs = File.OpenRead(l.jarFilePath);
|
using var fs = File.OpenRead(l.jarFilePath);
|
||||||
@ -64,15 +72,30 @@ public class LibrariesDownloadTaskFactory : INetworkTaskFactory
|
|||||||
|
|
||||||
private async Task Download(NetworkProgressReporter pr, CancellationToken ct)
|
private async Task Download(NetworkProgressReporter pr, CancellationToken ct)
|
||||||
{
|
{
|
||||||
Приложение.Логгер.LogInfo(nameof(Сеть), "started downloading libraries");
|
Приложение.Логгер.LogInfo(nameof(Сеть), $"started downloading libraries '{_descriptor.id}'");
|
||||||
ParallelOptions opt = new() { MaxDegreeOfParallelism = ParallelDownloadsN, CancellationToken = ct };
|
ParallelOptions opt = new() { MaxDegreeOfParallelism = ParallelDownloadsN, CancellationToken = ct };
|
||||||
await Parallel.ForEachAsync(_libsToDownload, opt, async (l, _ct) =>
|
await Parallel.ForEachAsync(_libsToDownload, opt, async (l, _ct) =>
|
||||||
{
|
{
|
||||||
Приложение.Логгер.LogDebug(nameof(Сеть),
|
Приложение.Логгер.LogDebug(nameof(Сеть),
|
||||||
$"downloading library '{l.name}' to '{l.jarFilePath}'");
|
$"downloading library '{l.name}' to '{l.jarFilePath}'");
|
||||||
await DownloadFileHTTP(l.artifact.url, l.jarFilePath, _ct, pr.AddBytesCount);
|
await DownloadFileHTTP(l.artifact.url, l.jarFilePath, _ct, pr.AddBytesCount);
|
||||||
//TODO: extract natives from jar
|
if (l is Libraries.NativeLib n)
|
||||||
|
{
|
||||||
|
var zipf = File.OpenRead(n.jarFilePath);
|
||||||
|
ZipFile.ExtractToDirectory(zipf, _nativesDir.ToString(), true);
|
||||||
|
if (n.extractionOptions?.exclude != null)
|
||||||
|
{
|
||||||
|
foreach (var excluded in n.extractionOptions.exclude)
|
||||||
|
{
|
||||||
|
IOPath path = Path.Concat(_nativesDir, excluded);
|
||||||
|
if(Directory.Exists(path))
|
||||||
|
Directory.Delete(path);
|
||||||
|
if(File.Exists(path))
|
||||||
|
File.Delete(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
Приложение.Логгер.LogInfo(nameof(Сеть), "finished downloading libraries");
|
Приложение.Логгер.LogInfo(nameof(Сеть), $"finished downloading libraries '{_descriptor.id}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using DTLib.Extensions;
|
using DTLib.Extensions;
|
||||||
|
using Млаумчерб.Клиент.видимое;
|
||||||
using Млаумчерб.Клиент.классы;
|
using Млаумчерб.Клиент.классы;
|
||||||
using static Млаумчерб.Клиент.сеть.Сеть;
|
using static Млаумчерб.Клиент.сеть.Сеть;
|
||||||
|
|
||||||
@ -7,11 +8,11 @@ namespace Млаумчерб.Клиент.сеть.NetworkTaskFactories;
|
|||||||
|
|
||||||
public class VersionFileDownloadTaskFactory : INetworkTaskFactory
|
public class VersionFileDownloadTaskFactory : INetworkTaskFactory
|
||||||
{
|
{
|
||||||
private VersionDescriptor _descriptor;
|
private GameVersionDescriptor _descriptor;
|
||||||
private IOPath _filePath;
|
private IOPath _filePath;
|
||||||
private SHA1 _hasher;
|
private SHA1 _hasher;
|
||||||
|
|
||||||
public VersionFileDownloadTaskFactory(VersionDescriptor descriptor)
|
public VersionFileDownloadTaskFactory(GameVersionDescriptor descriptor)
|
||||||
{
|
{
|
||||||
_descriptor = descriptor;
|
_descriptor = descriptor;
|
||||||
_filePath = Пути.GetVersionJarFilePath(_descriptor.id);
|
_filePath = Пути.GetVersionJarFilePath(_descriptor.id);
|
||||||
@ -46,8 +47,10 @@ public class VersionFileDownloadTaskFactory : INetworkTaskFactory
|
|||||||
return _descriptor.downloads.client.size;
|
return _descriptor.downloads.client.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task Download(NetworkProgressReporter pr, CancellationToken ct)
|
private async Task Download(NetworkProgressReporter pr, CancellationToken ct)
|
||||||
{
|
{
|
||||||
return DownloadFileHTTP(_descriptor.downloads.client.url, _filePath, ct, pr.AddBytesCount);
|
Приложение.Логгер.LogInfo(nameof(Сеть), $"started downloading version file '{_descriptor.id}'");
|
||||||
|
await DownloadFileHTTP(_descriptor.downloads.client.url, _filePath, ct, pr.AddBytesCount);
|
||||||
|
Приложение.Логгер.LogInfo(nameof(Сеть), $"finished downloading version file '{_descriptor.id}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public static class Сеть
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var manifestText = await http.GetStringAsync(url);
|
var manifestText = await http.GetStringAsync(url);
|
||||||
var catalog = JsonConvert.DeserializeObject<VersionCatalog>(manifestText);
|
var catalog = JsonConvert.DeserializeObject<GameVersionCatalog>(manifestText);
|
||||||
if (catalog != null)
|
if (catalog != null)
|
||||||
descriptors.AddRange(catalog.versions);
|
descriptors.AddRange(catalog.versions);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user