forge support
This commit is contained in:
@@ -43,15 +43,7 @@ public class LibrariesDownloadTaskFactory : INetworkTaskFactory
|
||||
|
||||
foreach (var l in _libraries.Libs)
|
||||
{
|
||||
// Forge installer downloads some libraries manually.
|
||||
// Such libraries have empty url in descriptor.
|
||||
if(l.jarFilePath is null)
|
||||
{
|
||||
LauncherApp.Logger.LogDebug(nameof(NetworkHelper), $"library artifact has empty url: '{l.name}'");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!File.Exists(l.jarFilePath.Value))
|
||||
if (!File.Exists(l.jarFilePath))
|
||||
{
|
||||
_libsToDownload.Add(l);
|
||||
}
|
||||
@@ -61,7 +53,7 @@ public class LibrariesDownloadTaskFactory : INetworkTaskFactory
|
||||
}
|
||||
else if (checkHashes)
|
||||
{
|
||||
using var fs = File.OpenRead(l.jarFilePath.Value);
|
||||
using var fs = File.OpenRead(l.jarFilePath);
|
||||
string hash = _hasher.ComputeHash(fs).HashToString();
|
||||
if(hash != l.artifact.sha1)
|
||||
_libsToDownload.Add(l);
|
||||
@@ -91,12 +83,12 @@ public class LibrariesDownloadTaskFactory : INetworkTaskFactory
|
||||
await Parallel.ForEachAsync(_libsToDownload, opt, async (l, _ct) =>
|
||||
{
|
||||
LauncherApp.Logger.LogDebug(nameof(NetworkHelper), $"downloading library '{l.name}' to '{l.jarFilePath}'");
|
||||
if(l.jarFilePath is null)
|
||||
throw new Exception("jarFilePath is null");
|
||||
await DownloadFile(l.artifact.url, l.jarFilePath.Value, _ct, pr.AddBytesCount);
|
||||
if(string.IsNullOrEmpty(l.artifact.url))
|
||||
throw new Exception($"library '{l.name}' doesn't have a url to download");
|
||||
await DownloadFile(l.artifact.url, l.jarFilePath, _ct, pr.AddBytesCount);
|
||||
if (l is Libraries.NativeLib n)
|
||||
{
|
||||
var zipf = File.OpenRead(n.jarFilePath!.Value);
|
||||
var zipf = File.OpenRead(n.jarFilePath);
|
||||
ZipFile.ExtractToDirectory(zipf, _nativesDir.ToString(), true);
|
||||
if (n.extractionOptions?.exclude != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user