mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Tons of warning fixes
This commit is contained in:
parent
4e2f8b585d
commit
1511b69b4f
@ -74,7 +74,7 @@ public static class AsyncParallelExtensions
|
||||
/// <typeparam name="TJob"></typeparam>
|
||||
/// <typeparam name="TOut"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static async IAsyncEnumerable<TOut> PMapAllBatched<TIn, TJob, TOut>(this IEnumerable<TIn> coll,
|
||||
public static async IAsyncEnumerable<TOut> PMapAllBatchedAsync<TIn, TJob, TOut>(this IEnumerable<TIn> coll,
|
||||
IResource<TJob> limiter, Func<TIn, Task<TOut>> mapFn)
|
||||
{
|
||||
var asList = coll.ToList();
|
||||
@ -103,6 +103,47 @@ public static class AsyncParallelExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Faster version of PMapAll for when the function invocation will take a very small amount of time
|
||||
/// batches all the inputs into N groups and executes them all on one task, where N is the number of
|
||||
/// threads supported by the limiter
|
||||
/// </summary>
|
||||
/// <param name="coll"></param>
|
||||
/// <param name="limiter"></param>
|
||||
/// <param name="mapFn"></param>
|
||||
/// <typeparam name="TIn"></typeparam>
|
||||
/// <typeparam name="TJob"></typeparam>
|
||||
/// <typeparam name="TOut"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static async IAsyncEnumerable<TOut> PMapAllBatched<TIn, TJob, TOut>(this IEnumerable<TIn> coll,
|
||||
IResource<TJob> limiter, Func<TIn, TOut> mapFn)
|
||||
{
|
||||
var asList = coll.ToList();
|
||||
|
||||
var tasks = new List<Task<List<TOut>>>();
|
||||
|
||||
tasks.AddRange(Enumerable.Range(0, limiter.MaxTasks).Select(i => Task.Run(async () =>
|
||||
{
|
||||
using var job = await limiter.Begin(limiter.Name, asList.Count / limiter.MaxTasks, CancellationToken.None);
|
||||
var list = new List<TOut>();
|
||||
for (var idx = i; idx < asList.Count; idx += limiter.MaxTasks)
|
||||
{
|
||||
job.ReportNoWait(1);
|
||||
list.Add( mapFn(asList[idx]));
|
||||
}
|
||||
|
||||
return list;
|
||||
})));
|
||||
|
||||
foreach (var result in tasks)
|
||||
{
|
||||
foreach (var itm in (await result))
|
||||
{
|
||||
yield return itm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Faster version of PMapAll for when the function invocation will take a very small amount of time
|
||||
/// batches all the inputs into N groups and executes them all on one task, where N is the number of
|
||||
|
@ -476,7 +476,7 @@ public abstract class ACompiler
|
||||
|
||||
NextStep("Compiling", "Generating Patches", toBuild.Length);
|
||||
|
||||
var allFiles = (await toBuild.PMapAllBatched(CompilerLimiter, async f =>
|
||||
var allFiles = (await toBuild.PMapAllBatchedAsync(CompilerLimiter, async f =>
|
||||
{
|
||||
UpdateProgress(1);
|
||||
return new[]
|
||||
@ -504,7 +504,7 @@ public abstract class ACompiler
|
||||
if (toBuild.Length == 0) return;
|
||||
|
||||
NextStep("Compiling", "Generating Patch Files", toBuild.Length);
|
||||
await toBuild.PMapAllBatched(CompilerLimiter, async patch =>
|
||||
await toBuild.PMapAllBatchedAsync(CompilerLimiter, async patch =>
|
||||
{
|
||||
UpdateProgress(1);
|
||||
await using var src = TempPath(patch.FromHash).Open(FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
|
@ -141,7 +141,7 @@ public class MO2Compiler : ACompiler
|
||||
var stack = MakeStack();
|
||||
|
||||
NextStep("Compiling", "Running Compilation Stack", AllFiles.Count);
|
||||
var results = await AllFiles.PMapAllBatched(CompilerLimiter, f =>
|
||||
var results = await AllFiles.PMapAllBatchedAsync(CompilerLimiter, f =>
|
||||
{
|
||||
UpdateProgress(1);
|
||||
return RunStack(stack, f);
|
||||
|
@ -5,9 +5,10 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>$(VERSION)</Version>
|
||||
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
|
||||
<NoWarn>CS8600</NoWarn>
|
||||
<NoWarn>CS8601</NoWarn>
|
||||
<NoWarn>CS8618</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<NoWarn>CS8600,CS8601,CS8618,CS8604</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Text;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Paths;
|
||||
#pragma warning disable SYSLIB0001
|
||||
|
||||
namespace Wabbajack.Compression.BSA;
|
||||
|
||||
|
@ -20,10 +20,11 @@ public class Builder : IBuilder
|
||||
_files = new (TES3File state, Stream data)[_state.FileCount];
|
||||
}
|
||||
|
||||
public async ValueTask AddFile(AFile state, Stream src, CancellationToken token)
|
||||
public ValueTask AddFile(AFile state, Stream src, CancellationToken token)
|
||||
{
|
||||
var tesState = (TES3File) state;
|
||||
_files[state.Index] = (tesState, src);
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
|
||||
public async ValueTask Build(Stream file, CancellationToken token)
|
||||
|
@ -110,10 +110,8 @@ public class ZipReader : IAsyncDisposable
|
||||
public async Task<ExtractedEntry[]> GetFiles()
|
||||
{
|
||||
var (sigOffset, totalCentralDirectoryRecords, centralDirectoryOffset) = await ReadZip32EODR(0);
|
||||
var isZip64 = false;
|
||||
if (centralDirectoryOffset == uint.MaxValue)
|
||||
{
|
||||
isZip64 = true;
|
||||
(sigOffset, totalCentralDirectoryRecords, centralDirectoryOffset) = await ReadZip64EODR(sigOffset);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class BethesdaDownloader : ADownloader<DTOs.DownloadStates.Bethesda>, IUr
|
||||
var hasher = new xxHashAlgorithm(0);
|
||||
Hash finalHash = default;
|
||||
|
||||
var aesKey = depot.ExInfoA.ToArray();
|
||||
var aesKey = depot!.ExInfoA.ToArray();
|
||||
var aesIV = depot.ExInfoB.Take(16).ToArray();
|
||||
|
||||
await chunks.PMapAll(async chunk =>
|
||||
@ -100,7 +100,7 @@ public class BethesdaDownloader : ADownloader<DTOs.DownloadStates.Bethesda>, IUr
|
||||
|
||||
public override async Task<bool> Prepare()
|
||||
{
|
||||
await _client.CDPAuth(CancellationToken.None);
|
||||
await _client.CdpAuth(CancellationToken.None);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -99,9 +99,9 @@ public class DownloadDispatcher
|
||||
return hash;
|
||||
}
|
||||
|
||||
public async Task<IDownloadState?> ResolveArchive(IReadOnlyDictionary<string, string> ini)
|
||||
public Task<IDownloadState?> ResolveArchive(IReadOnlyDictionary<string, string> ini)
|
||||
{
|
||||
return _downloaders.Select(downloader => downloader.Resolve(ini)).FirstOrDefault(result => result != null);
|
||||
return Task.FromResult(_downloaders.Select(downloader => downloader.Resolve(ini)).FirstOrDefault(result => result != null));
|
||||
}
|
||||
|
||||
public async Task<bool> Verify(Archive a, CancellationToken token)
|
||||
@ -265,7 +265,7 @@ public class DownloadDispatcher
|
||||
return Downloader(archive).IsAllowed(allowList, archive.State);
|
||||
}
|
||||
|
||||
public async Task<bool> IsAllowed(ModUpgradeRequest request, CancellationToken allowList)
|
||||
public Task<bool> IsAllowed(ModUpgradeRequest request, CancellationToken allowList)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -288,9 +288,9 @@ public class DownloadDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<IDownloader>> AllDownloaders(IEnumerable<IDownloadState> downloadStates)
|
||||
public Task<IEnumerable<IDownloader>> AllDownloaders(IEnumerable<IDownloadState> downloadStates)
|
||||
{
|
||||
return downloadStates.Select(d => Downloader(new Archive {State = d})).Distinct();
|
||||
return Task.FromResult(downloadStates.Select(d => Downloader(new Archive {State = d})).Distinct());
|
||||
}
|
||||
|
||||
public bool Matches(Archive archive, ServerAllowList mirrorAllowList)
|
||||
|
@ -40,9 +40,9 @@ public class GoogleDriveDownloader : ADownloader<DTOs.DownloadStates.GoogleDrive
|
||||
_downloader = downloader;
|
||||
}
|
||||
|
||||
public override async Task<bool> Prepare()
|
||||
public override Task<bool> Prepare()
|
||||
{
|
||||
return true;
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public override bool IsAllowed(ServerAllowList allowList, IDownloadState state)
|
||||
|
@ -68,9 +68,9 @@ public class HttpDownloader : ADownloader<DTOs.DownloadStates.Http>, IUrlDownloa
|
||||
return null;
|
||||
}
|
||||
|
||||
public override async Task<bool> Prepare()
|
||||
public override Task<bool> Prepare()
|
||||
{
|
||||
return true;
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public override bool IsAllowed(ServerAllowList allowList, IDownloadState state)
|
||||
@ -155,10 +155,10 @@ public class HttpDownloader : ADownloader<DTOs.DownloadStates.Http>, IUrlDownloa
|
||||
return new[] {$"directURL={state.Url}"};
|
||||
}
|
||||
|
||||
public async ValueTask<Stream> GetChunkedSeekableStream(Archive archive, CancellationToken token)
|
||||
public ValueTask<Stream> GetChunkedSeekableStream(Archive archive, CancellationToken token)
|
||||
{
|
||||
var state = archive.State as DTOs.DownloadStates.Http;
|
||||
return new ChunkedSeekableDownloader(this, archive, state!);
|
||||
return ValueTask.FromResult<Stream>(new ChunkedSeekableDownloader(this, archive, state!));
|
||||
}
|
||||
|
||||
public class ChunkedSeekableDownloader : AChunkedBufferingStream
|
||||
|
@ -101,11 +101,11 @@ public class AIPS4OAuth2Downloader<TDownloader, TLogin, TState> : ADownloader<TS
|
||||
if (useOAuth2)
|
||||
{
|
||||
msg.Headers.Add("User-Agent", _appInfo.UserAgent);
|
||||
msg.Headers.Add("Authorization", $"Bearer {loginData.ResultState.AccessToken}");
|
||||
msg.Headers.Add("Authorization", $"Bearer {loginData!.ResultState.AccessToken}");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.AddCookies(loginData.Cookies)
|
||||
msg.AddCookies(loginData!.Cookies)
|
||||
.AddChromeAgent();
|
||||
}
|
||||
|
||||
@ -156,16 +156,16 @@ public class AIPS4OAuth2Downloader<TDownloader, TLogin, TState> : ADownloader<TS
|
||||
{
|
||||
var downloads = await GetDownloads(state.IPS4Mod, token);
|
||||
var fileEntry = downloads.Files.FirstOrDefault(f => f.Name == state.IPS4File);
|
||||
var msg = new HttpRequestMessage(HttpMethod.Get, fileEntry.Url);
|
||||
var msg = new HttpRequestMessage(HttpMethod.Get, fileEntry!.Url);
|
||||
msg.Version = new Version(2, 0);
|
||||
msg.Headers.Add("User-Agent", _appInfo.UserAgent);
|
||||
return await _downloader.Download(msg, destination, job, token);
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task<bool> Prepare()
|
||||
public override Task<bool> Prepare()
|
||||
{
|
||||
return _loginInfo.HaveToken();
|
||||
return Task.FromResult(_loginInfo.HaveToken());
|
||||
}
|
||||
|
||||
public override bool IsAllowed(ServerAllowList allowList, IDownloadState state)
|
||||
|
@ -16,7 +16,6 @@ public class ManualDownloader : ADownloader<DTOs.DownloadStates.Manual>, IProxya
|
||||
{
|
||||
private readonly ILogger<ManualDownloader> _logger;
|
||||
private readonly IUserInterventionHandler _interventionHandler;
|
||||
private readonly IResource<HttpClient> _limiter;
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public ManualDownloader(ILogger<ManualDownloader> logger, IUserInterventionHandler interventionHandler, HttpClient client)
|
||||
@ -59,9 +58,9 @@ public class ManualDownloader : ADownloader<DTOs.DownloadStates.Manual>, IProxya
|
||||
}
|
||||
|
||||
|
||||
public override async Task<bool> Prepare()
|
||||
public override Task<bool> Prepare()
|
||||
{
|
||||
return true;
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public override bool IsAllowed(ServerAllowList allowList, IDownloadState state)
|
||||
@ -88,9 +87,9 @@ public class ManualDownloader : ADownloader<DTOs.DownloadStates.Manual>, IProxya
|
||||
}
|
||||
|
||||
public override Priority Priority { get; } = Priority.Lowest;
|
||||
public override async Task<bool> Verify(Archive archive, DTOs.DownloadStates.Manual archiveState, IJob job, CancellationToken token)
|
||||
public override Task<bool> Verify(Archive archive, DTOs.DownloadStates.Manual archiveState, IJob job, CancellationToken token)
|
||||
{
|
||||
return true;
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public override IEnumerable<string> MetaIni(Archive a, DTOs.DownloadStates.Manual state)
|
||||
|
@ -113,7 +113,7 @@ public class MediaFireDownloader : ADownloader<DTOs.DownloadStates.MediaFire>, I
|
||||
{
|
||||
var bodyData = await result.Content.ReadAsStringAsync((CancellationToken) token);
|
||||
if (job != null)
|
||||
await job.Report((int) job.Size, (CancellationToken) token);
|
||||
await job.Report((int) (job.Size ?? 0), (CancellationToken) token);
|
||||
var body = new HtmlDocument();
|
||||
body.LoadHtml(bodyData);
|
||||
var node = body.DocumentNode.DescendantsAndSelf().FirstOrDefault(d => d.HasClass("input") && d.HasClass("popsok") &&
|
||||
|
@ -67,7 +67,7 @@ public class MegaDownloader : ADownloader<Mega>, IUrlDownloader, IProxyable
|
||||
if (!_apiClient.IsLoggedIn)
|
||||
await _apiClient.LoginAsync();
|
||||
|
||||
await using var ins = await _apiClient.DownloadAsync(state.Url, cancellationToken: token);
|
||||
await using var ins = await _apiClient.DownloadAsync(state!.Url, cancellationToken: token);
|
||||
return await fn(ins);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ using Wabbajack.RateLimiter;
|
||||
|
||||
namespace Wabbajack.Downloaders.ModDB;
|
||||
|
||||
public class ModDBDownloader : ADownloader<DTOs.DownloadStates.ModDB>, IUrlDownloader, IProxyable
|
||||
public class ModDBDownloader : ADownloader<DTOs.DownloadStates.ModDB>, IProxyable
|
||||
{
|
||||
private readonly IHttpDownloader _downloader;
|
||||
private readonly HttpClient _httpClient;
|
||||
@ -98,8 +98,7 @@ public class ModDBDownloader : ADownloader<DTOs.DownloadStates.ModDB>, IUrlDownl
|
||||
throw;
|
||||
}
|
||||
}
|
||||
_logger.LogError("All servers were invalid downloading from ModDB {Uri}", state.Url);
|
||||
return default;
|
||||
throw new Exception($"All servers were invalid downloading from ModDB {state!.Url}");
|
||||
}
|
||||
|
||||
public override async Task<Hash> Download(Archive archive, DTOs.DownloadStates.ModDB state,
|
||||
|
@ -33,7 +33,6 @@ public class WabbajackCDNDownloader : ADownloader<WabbajackCDN>, IUrlDownloader,
|
||||
private readonly HttpClient _client;
|
||||
private readonly DTOSerializer _dtos;
|
||||
private readonly ILogger<WabbajackCDNDownloader> _logger;
|
||||
private readonly ParallelOptions _parallelOptions;
|
||||
private readonly IResource<HttpClient> _limiter;
|
||||
|
||||
public WabbajackCDNDownloader(ILogger<WabbajackCDNDownloader> logger, HttpClient client, IResource<HttpClient> limiter, DTOSerializer dtos)
|
||||
|
@ -152,10 +152,10 @@ public abstract class AInstaller<T>
|
||||
return await fullPath.ReadAllBytesAsync();
|
||||
}
|
||||
|
||||
public async Task<Stream> InlinedFileStream(RelativePath inlinedFile)
|
||||
public Task<Stream> InlinedFileStream(RelativePath inlinedFile)
|
||||
{
|
||||
var fullPath = ExtractedModlistFolder.Path.Combine(inlinedFile);
|
||||
return fullPath.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
return Task.FromResult(fullPath.Open(FileMode.Open, FileAccess.Read, FileShare.Read));
|
||||
}
|
||||
|
||||
public static async Task<ModList> LoadFromFile(DTOSerializer serializer, AbsolutePath path)
|
||||
@ -200,7 +200,7 @@ public abstract class AInstaller<T>
|
||||
await _vfs.BackfillMissing();
|
||||
}
|
||||
|
||||
public async Task BuildFolderStructure()
|
||||
public Task BuildFolderStructure()
|
||||
{
|
||||
NextStep(Consts.StepPreparing, "Building Folder Structure", 0);
|
||||
_logger.LogInformation("Building Folder Structure");
|
||||
@ -209,6 +209,7 @@ public abstract class AInstaller<T>
|
||||
.Select(d => _configuration.Install.Combine(d.To.Parent))
|
||||
.Distinct()
|
||||
.Do(f => f.CreateDirectory());
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task InstallArchives(CancellationToken token)
|
||||
@ -406,7 +407,7 @@ public abstract class AInstaller<T>
|
||||
.ToList();
|
||||
|
||||
_logger.LogInformation("Getting archive sizes");
|
||||
var hashDict = (await allFiles.PMapAll(_limiter, async x => (x, x.Size())).ToList())
|
||||
var hashDict = (await allFiles.PMapAllBatched(_limiter, x => (x, x.Size())).ToList())
|
||||
.GroupBy(f => f.Item2)
|
||||
.ToDictionary(g => g.Key, g => g.Select(v => v.x));
|
||||
|
||||
@ -485,7 +486,7 @@ public abstract class AInstaller<T>
|
||||
|
||||
NextStep(Consts.StepPreparing, "Looking for files to delete", 0);
|
||||
await _configuration.Install.EnumerateFiles()
|
||||
.PMapAllBatched(_limiter, async f =>
|
||||
.PMapAllBatched(_limiter, f =>
|
||||
{
|
||||
var relativeTo = f.RelativeTo(_configuration.Install);
|
||||
if (indexed.ContainsKey(relativeTo) || f.InFolder(_configuration.Downloads))
|
||||
@ -541,7 +542,7 @@ public abstract class AInstaller<T>
|
||||
var existingfiles = _configuration.Install.EnumerateFiles().ToHashSet();
|
||||
|
||||
NextStep(Consts.StepPreparing, "Looking for unmodified files", 0);
|
||||
await indexed.Values.PMapAllBatched(_limiter, async d =>
|
||||
await indexed.Values.PMapAllBatchedAsync(_limiter, async d =>
|
||||
{
|
||||
// Bit backwards, but we want to return null for
|
||||
// all files we *want* installed. We return the files
|
||||
|
@ -154,10 +154,10 @@ public class StandardInstaller : AInstaller<StandardInstaller>
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task RemapMO2File()
|
||||
private Task RemapMO2File()
|
||||
{
|
||||
var iniFile = _configuration.Install.Combine("ModOrganizer.ini");
|
||||
if (!iniFile.FileExists()) return;
|
||||
if (!iniFile.FileExists()) return Task.CompletedTask;
|
||||
|
||||
_logger.LogInformation("Remapping ModOrganizer.ini");
|
||||
|
||||
@ -165,6 +165,7 @@ public class StandardInstaller : AInstaller<StandardInstaller>
|
||||
var settings = iniData["Settings"];
|
||||
settings["download_directory"] = _configuration.Downloads.ToString().Replace("\\", "/");
|
||||
iniData.SaveIniFile(iniFile);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void CreateOutputMods()
|
||||
@ -361,7 +362,7 @@ public class StandardInstaller : AInstaller<StandardInstaller>
|
||||
if (data.Sections["Display"]["iSize W"] != null && data.Sections["Display"]["iSize H"] != null)
|
||||
{
|
||||
data.Sections["Display"]["iSize W"] =
|
||||
_configuration.SystemParameters.ScreenWidth.ToString(CultureInfo.CurrentCulture);
|
||||
_configuration.SystemParameters!.ScreenWidth.ToString(CultureInfo.CurrentCulture);
|
||||
data.Sections["Display"]["iSize H"] =
|
||||
_configuration.SystemParameters.ScreenHeight.ToString(CultureInfo.CurrentCulture);
|
||||
modified = true;
|
||||
@ -371,7 +372,7 @@ public class StandardInstaller : AInstaller<StandardInstaller>
|
||||
if (data.Sections["MEMORY"]["VideoMemorySizeMb"] != null)
|
||||
{
|
||||
data.Sections["MEMORY"]["VideoMemorySizeMb"] =
|
||||
_configuration.SystemParameters.EnbLEVRAMSize.ToString(CultureInfo.CurrentCulture);
|
||||
_configuration.SystemParameters!.EnbLEVRAMSize.ToString(CultureInfo.CurrentCulture);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
@ -397,7 +398,7 @@ public class StandardInstaller : AInstaller<StandardInstaller>
|
||||
if (data.Sections["Render"]["Resolution"] != null)
|
||||
{
|
||||
data.Sections["Render"]["Resolution"] =
|
||||
$"{_configuration.SystemParameters.ScreenWidth.ToString(CultureInfo.CurrentCulture)}x{_configuration.SystemParameters.ScreenHeight.ToString(CultureInfo.CurrentCulture)}";
|
||||
$"{_configuration.SystemParameters!.ScreenWidth.ToString(CultureInfo.CurrentCulture)}x{_configuration.SystemParameters.ScreenHeight.ToString(CultureInfo.CurrentCulture)}";
|
||||
modified = true;
|
||||
}
|
||||
|
||||
@ -464,7 +465,7 @@ public class StandardInstaller : AInstaller<StandardInstaller>
|
||||
.ToList();
|
||||
NextStep("Installing", "Generating ZEdit Merges", patches.Count);
|
||||
|
||||
await patches.PMapAllBatched(_limiter, async m =>
|
||||
await patches.PMapAllBatchedAsync(_limiter, async m =>
|
||||
{
|
||||
UpdateProgress(1);
|
||||
_logger.LogInformation("Generating zEdit merge: {to}", m.To);
|
||||
|
@ -7,9 +7,10 @@ namespace Wabbajack.Installer.Utilities;
|
||||
|
||||
public class BinaryPatching
|
||||
{
|
||||
public static async ValueTask ApplyPatch(Stream input, Stream deltaStream, Stream output)
|
||||
public static ValueTask ApplyPatch(Stream input, Stream deltaStream, Stream output)
|
||||
{
|
||||
var deltaApplier = new DeltaApplier();
|
||||
deltaApplier.Apply(input, new BinaryDeltaReader(deltaStream, new NullProgressReporter()), output);
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
@ -7,6 +7,10 @@
|
||||
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<NoWarn>CS8600,CS8601,CS8618,CS8604</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Wabbajack.Downloaders.Dispatcher\Wabbajack.Downloaders.Dispatcher.csproj" />
|
||||
<ProjectReference Include="..\Wabbajack.Downloaders.GameFile\Wabbajack.Downloaders.GameFile.csproj" />
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Net.Http.Json;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
@ -25,12 +26,12 @@ public class Client
|
||||
private readonly ILogger<Client> _logger;
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly JsonSerializerOptions _jsonOptions;
|
||||
private CDPAuthResponse? _entitlementData = null;
|
||||
public const string AgentPlatform = "WINDOWS";
|
||||
public const string AgentProduct = "FALLOUT4";
|
||||
public const string AgentLanguage = "en";
|
||||
private const string ClientAPIKey = "FeBqmQA8wxd94RtqymKwzmtcQcaA5KHOpDkQBSegx4WePeluZTCIm5scoeKTbmGl";
|
||||
private const string ClientId = "95578d65-45bf-4a03-b7f7-a43d29b9467d";
|
||||
private CDPAuthResponse? _entitlementData;
|
||||
private const string AgentPlatform = "WINDOWS";
|
||||
private const string AgentProduct = "FALLOUT4";
|
||||
private const string AgentLanguage = "en";
|
||||
private const string ClientApiKey = "FeBqmQA8wxd94RtqymKwzmtcQcaA5KHOpDkQBSegx4WePeluZTCIm5scoeKTbmGl";
|
||||
//private const string ClientId = "95578d65-45bf-4a03-b7f7-a43d29b9467d";
|
||||
private const string AgentVersion = $"{AgentProduct};;BDK;1.0013.99999.1;{AgentPlatform}";
|
||||
private string FingerprintKey { get; set; }
|
||||
|
||||
@ -50,14 +51,15 @@ public class Client
|
||||
|
||||
public async Task Login(CancellationToken token)
|
||||
{
|
||||
_logger.LogInformation("Logging into BethesdaNet");
|
||||
var loginData = await _tokenProvider.Get();
|
||||
var msg = MakeMessage(HttpMethod.Post, new Uri($"https://api.bethesda.net/beam/accounts/login/{loginData!.Username}"));
|
||||
msg.Headers.Add("X-Client-API-key", ClientAPIKey);
|
||||
msg.Headers.Add("X-Client-API-key", ClientApiKey);
|
||||
msg.Headers.Add("x-src-fp", FingerprintKey);
|
||||
msg.Headers.Add("X-Platform", AgentPlatform);
|
||||
msg.Content = new StringContent(JsonSerializer.Serialize(new BeamLogin
|
||||
{
|
||||
Password = loginData!.Password,
|
||||
Password = loginData.Password,
|
||||
Language = AgentLanguage
|
||||
}, _jsonOptions), Encoding.UTF8, "application/json");
|
||||
|
||||
@ -71,10 +73,10 @@ public class Client
|
||||
await _tokenProvider.SetToken(loginData);
|
||||
}
|
||||
|
||||
public async Task CDPAuth(CancellationToken token)
|
||||
public async Task CdpAuth(CancellationToken token)
|
||||
{
|
||||
var state = await _tokenProvider.Get();
|
||||
if (string.IsNullOrEmpty(state.BeamResponse?.AccessToken))
|
||||
if (string.IsNullOrEmpty(state!.BeamResponse?.AccessToken))
|
||||
throw new Exception("Can't get CDPAuth before Bethesda Net login");
|
||||
|
||||
var msg = MakeMessage(HttpMethod.Post, new Uri("https://api.bethesda.net/cdp-user/auth"));
|
||||
@ -106,7 +108,7 @@ public class Client
|
||||
private void SetFingerprint()
|
||||
{
|
||||
var keyBytes = new byte[20];
|
||||
using (var rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
|
||||
using (var rng = RandomNumberGenerator.Create())
|
||||
rng.GetBytes(keyBytes);
|
||||
|
||||
FingerprintKey = string.Concat(Array.ConvertAll(keyBytes, x => x.ToString("X2")));
|
||||
@ -145,13 +147,7 @@ public class Client
|
||||
private async Task EnsureAuthed(CancellationToken token)
|
||||
{
|
||||
if (_entitlementData == null)
|
||||
await CDPAuth(token);
|
||||
}
|
||||
|
||||
private int ProductId(Game game)
|
||||
{
|
||||
if (game == Game.SkyrimSpecialEdition) return 4;
|
||||
return 0;
|
||||
await CdpAuth(token);
|
||||
}
|
||||
|
||||
public async Task<Depot?> GetDepots(Bethesda state, CancellationToken token)
|
||||
|
@ -34,8 +34,6 @@ public class Client : IDisposable
|
||||
private string? _twoFactorCode;
|
||||
private string? _authCode;
|
||||
private readonly IUserInterventionHandler _interventionHandler;
|
||||
private bool _isConnected;
|
||||
private bool _isLoggedIn;
|
||||
private bool _haveSigFile;
|
||||
|
||||
public TaskCompletionSource _licenseRequest = new();
|
||||
@ -93,8 +91,6 @@ public class Client : IDisposable
|
||||
|
||||
_manager.Subscribe<SteamUser.UpdateMachineAuthCallback>( OnUpdateMachineAuthCallback );
|
||||
|
||||
_isConnected = false;
|
||||
_isLoggedIn = false;
|
||||
_haveSigFile = false;
|
||||
|
||||
new Thread(() =>
|
||||
@ -170,7 +166,6 @@ public class Client : IDisposable
|
||||
|
||||
private void OnLoggedOff(SteamUser.LoggedOffCallback obj)
|
||||
{
|
||||
_isLoggedIn = false;
|
||||
}
|
||||
|
||||
private void OnLoggedOn(SteamUser.LoggedOnCallback callback)
|
||||
@ -206,7 +201,6 @@ public class Client : IDisposable
|
||||
return;
|
||||
}
|
||||
|
||||
_isLoggedIn = true;
|
||||
_logger.LogInformation("Logged into Steam");
|
||||
if (_haveSigFile)
|
||||
_loginTask.SetResult();
|
||||
@ -215,7 +209,6 @@ public class Client : IDisposable
|
||||
|
||||
private void OnDisconnected(SteamClient.DisconnectedCallback obj)
|
||||
{
|
||||
_isConnected = false;
|
||||
_logger.LogInformation("Logged out");
|
||||
}
|
||||
|
||||
@ -240,8 +233,6 @@ public class Client : IDisposable
|
||||
_haveSigFile = false;
|
||||
}
|
||||
|
||||
_isConnected = true;
|
||||
|
||||
_steamUser.LogOn(new SteamUser.LogOnDetails
|
||||
{
|
||||
Username = state.User,
|
||||
|
@ -8,11 +8,4 @@
|
||||
<PropertyGroup>
|
||||
<NoWarn>CS8600,CS8601,CS8618,CS8604</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<HintPath>..\..\..\..\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\6.0.0-preview.6.21355.2\ref\net6.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user