bugfixes
This commit is contained in:
@@ -37,7 +37,13 @@ public class AssetsDownloadTaskFactory : INetworkTaskFactory
|
||||
}
|
||||
private async Task<bool> CheckFilesAsync(bool checkHashes)
|
||||
{
|
||||
if(!File.Exists(_indexFilePath))
|
||||
string assetIndexHash = "";
|
||||
if(checkHashes)
|
||||
{
|
||||
await using var fs = File.OpenRead(_indexFilePath);
|
||||
assetIndexHash = _hasher.ComputeHash(fs).HashToString();
|
||||
}
|
||||
if(!File.Exists(_indexFilePath) || (checkHashes && assetIndexHash != _descriptor.assetIndex.sha1))
|
||||
{
|
||||
LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"started downloading asset index to '{_indexFilePath}'");
|
||||
await DownloadFile(_descriptor.assetIndex.url, _indexFilePath);
|
||||
|
||||
@@ -7,13 +7,13 @@ using static Mlaumcherb.Client.Avalonia.сеть.NetworkHelper;
|
||||
|
||||
namespace Mlaumcherb.Client.Avalonia.сеть.TaskFactories;
|
||||
|
||||
public class VersionFileDownloadTaskFactory : INetworkTaskFactory
|
||||
public class VersionJarDownloadTaskFactory : INetworkTaskFactory
|
||||
{
|
||||
private GameVersionDescriptor _descriptor;
|
||||
private IOPath _filePath;
|
||||
private SHA1 _hasher;
|
||||
|
||||
public VersionFileDownloadTaskFactory(GameVersionDescriptor descriptor)
|
||||
public VersionJarDownloadTaskFactory(GameVersionDescriptor descriptor)
|
||||
{
|
||||
_descriptor = descriptor;
|
||||
_filePath = PathHelper.GetVersionJarFilePath(_descriptor.id);
|
||||
@@ -25,7 +25,7 @@ public class VersionFileDownloadTaskFactory : INetworkTaskFactory
|
||||
NetworkTask? networkTask = null;
|
||||
if (!CheckFiles(checkHashes))
|
||||
networkTask = new NetworkTask(
|
||||
$"version file '{_descriptor.id}'",
|
||||
$"version jar '{_descriptor.id}'",
|
||||
GetTotalSize(),
|
||||
Download
|
||||
);
|
||||
@@ -58,10 +58,10 @@ public class VersionFileDownloadTaskFactory : INetworkTaskFactory
|
||||
private async Task Download(NetworkProgressReporter pr, CancellationToken ct)
|
||||
{
|
||||
if (_descriptor.downloads is null)
|
||||
throw new Exception($"can't download version file '{_descriptor.id}' because it has no download url");
|
||||
throw new Exception($"can't download version jar '{_descriptor.id}' because it has no download url");
|
||||
|
||||
LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"started downloading version file '{_descriptor.id}'");
|
||||
LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"started downloading version jar '{_descriptor.id}'");
|
||||
await DownloadFile(_descriptor.downloads.client.url, _filePath, ct, pr.AddBytesCount);
|
||||
LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"finished downloading version file '{_descriptor.id}'");
|
||||
LauncherApp.Logger.LogInfo(nameof(NetworkHelper), $"finished downloading version jar '{_descriptor.id}'");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user