mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Wabbajack.Lib nullability finished up
This commit is contained in:
parent
a30bba2c0b
commit
806ff74893
@ -53,14 +53,14 @@ namespace Wabbajack.BuildServer.Test
|
||||
public async Task CanNotifyOfInis()
|
||||
{
|
||||
var archive =
|
||||
new Archive
|
||||
{
|
||||
State = new NexusDownloader.State
|
||||
new Archive(
|
||||
new NexusDownloader.State
|
||||
{
|
||||
Game = Game.SkyrimSpecialEdition,
|
||||
ModID = long.MaxValue >> 3,
|
||||
FileID = long.MaxValue >> 3,
|
||||
},
|
||||
})
|
||||
{
|
||||
Name = Guid.NewGuid().ToString()
|
||||
};
|
||||
Assert.True(await AuthorAPI.UploadPackagedInis(new[] {archive}));
|
||||
|
@ -121,19 +121,14 @@ namespace Wabbajack.BuildServer.Test
|
||||
|
||||
|
||||
|
||||
var modListData = new ModList
|
||||
{
|
||||
Archives = new List<Archive>
|
||||
{
|
||||
new Archive
|
||||
var modListData = new ModList();
|
||||
modListData.Archives.Add(
|
||||
new Archive(new HTTPDownloader.State(MakeURL("test_archive.txt")))
|
||||
{
|
||||
Hash = await test_archive_path.FileHashAsync(),
|
||||
Name = "test_archive",
|
||||
Size = test_archive_path.Size,
|
||||
State = new HTTPDownloader.State(MakeURL("test_archive.txt"))
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var modListPath = "test_modlist.wabbajack".RelativeTo(Fixture.ServerPublicFolder);
|
||||
|
||||
|
@ -42,10 +42,9 @@ namespace Wabbajack.BuildServer.Test
|
||||
{
|
||||
Payload = new IndexJob
|
||||
{
|
||||
Archive = new Archive
|
||||
Archive = new Archive(new HTTPDownloader.State(MakeURL("old_file_data.random")))
|
||||
{
|
||||
Name = "Oldfile",
|
||||
State = new HTTPDownloader.State(MakeURL("old_file_data.random"))
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -54,10 +53,9 @@ namespace Wabbajack.BuildServer.Test
|
||||
{
|
||||
Payload = new IndexJob
|
||||
{
|
||||
Archive = new Archive
|
||||
Archive = new Archive(new HTTPDownloader.State(MakeURL("new_file_data.random")))
|
||||
{
|
||||
Name = "Newfile",
|
||||
State = new HTTPDownloader.State(MakeURL("new_file_data.random"))
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -120,6 +118,5 @@ namespace Wabbajack.BuildServer.Test
|
||||
Assert.True($"{oldDataHash.ToHex()}_{newDataHash.ToHex()}".RelativeTo(Fixture.ServerUpdatesFolder).IsFile);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -102,10 +102,9 @@ namespace Wabbajack.BuildServer.Controllers
|
||||
Priority = Job.JobPriority.Low,
|
||||
Payload = new IndexJob
|
||||
{
|
||||
Archive = new Archive
|
||||
Archive = new Archive(data)
|
||||
{
|
||||
Name = entry.Name,
|
||||
State = data
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -175,15 +175,19 @@ namespace Wabbajack.BuildServer.Controllers
|
||||
var allMods = await api.GetModFiles(state.Game, state.ModID);
|
||||
var archive = allMods.files.Where(m => !string.IsNullOrEmpty(m.category_name))
|
||||
.OrderBy(s => Math.Abs((long)s.size - origSize))
|
||||
.Select(s => new Archive {
|
||||
Name = s.file_name,
|
||||
Size = (long)s.size,
|
||||
State = new NexusDownloader.State
|
||||
.Select(s =>
|
||||
new Archive(
|
||||
new NexusDownloader.State
|
||||
{
|
||||
Game = state.Game,
|
||||
ModID = state.ModID,
|
||||
FileID = s.file_id
|
||||
}}).FirstOrDefault();
|
||||
})
|
||||
{
|
||||
Name = s.file_name,
|
||||
Size = (long)s.size,
|
||||
})
|
||||
.FirstOrDefault();
|
||||
|
||||
if (archive == null)
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ namespace Wabbajack.BuildServer.Models.Jobs
|
||||
|
||||
var with_hash = states.Where(state => state.Hash != default).ToList();
|
||||
Utils.Log($"Inserting {with_hash.Count} jobs.");
|
||||
var jobs = states.Select(state => new IndexJob {Archive = new Archive {Name = state.GameFile.FileName.ToString(), State = state}})
|
||||
var jobs = states.Select(state => new IndexJob {Archive = new Archive(state) { Name = state.GameFile.FileName.ToString()}})
|
||||
.Select(j => new Job {Payload = j, RequiresNexus = j.UsesNexus})
|
||||
.ToList();
|
||||
|
||||
|
@ -38,10 +38,9 @@ namespace Wabbajack.BuildServer.Models.Jobs
|
||||
{
|
||||
Payload = new IndexJob
|
||||
{
|
||||
Archive = new Archive
|
||||
Archive = new Archive(new MegaDownloader.State(url.ToString()))
|
||||
{
|
||||
Name = Guid.NewGuid() + ".7z",
|
||||
State = new MegaDownloader.State(url.ToString())
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -56,12 +56,11 @@ namespace Wabbajack.BuildServer.Models.Jobs
|
||||
Priority = Job.JobPriority.High,
|
||||
Payload = new IndexJob
|
||||
{
|
||||
Archive = new Archive
|
||||
Archive = new Archive(new HTTPDownloader.State(file.Uri))
|
||||
{
|
||||
Name = file.MungedName,
|
||||
Size = file.Size,
|
||||
Hash = file.Hash,
|
||||
State = new HTTPDownloader.State(file.Uri)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -519,9 +519,8 @@ namespace Wabbajack.BuildServer.Model.Models
|
||||
var result = await conn.QueryFirstOrDefaultAsync<string>(@"SELECT JsonState FROM dbo.DownloadStates
|
||||
WHERE Hash = @hash AND PrimaryKey like 'NexusDownloader+State|%'",
|
||||
new {Hash = (long)startingHash});
|
||||
return result == null ? null : new Archive
|
||||
return result == null ? null : new Archive(result.FromJsonString<AbstractDownloadState>())
|
||||
{
|
||||
State = result.FromJsonString<AbstractDownloadState>(),
|
||||
Hash = startingHash
|
||||
};
|
||||
}
|
||||
@ -531,9 +530,8 @@ namespace Wabbajack.BuildServer.Model.Models
|
||||
await using var conn = await Open();
|
||||
var result = await conn.QueryFirstOrDefaultAsync<(long Hash, string State)>(@"SELECT Hash, JsonState FROM dbo.DownloadStates WHERE PrimaryKey = @PrimaryKey",
|
||||
new {PrimaryKey = primaryKey});
|
||||
return result == default ? null : new Archive
|
||||
return result == default ? null : new Archive(result.State.FromJsonString<AbstractDownloadState>())
|
||||
{
|
||||
State = result.State.FromJsonString<AbstractDownloadState>(),
|
||||
Hash = Hash.FromLong(result.Hash)
|
||||
};
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ namespace Wabbajack.CLI.Verbs
|
||||
|
||||
private static async Task<string> GetTextFileFromModlist(AbsolutePath archive, ModList modlist, RelativePath sourceID)
|
||||
{
|
||||
var installer = new MO2Installer(archive, modlist, default, default, null);
|
||||
var installer = new MO2Installer(archive, modlist, default, default, parameters: null!);
|
||||
byte[] bytes = await installer.LoadBytesFromPath(sourceID);
|
||||
return Encoding.Default.GetString(bytes);
|
||||
}
|
||||
@ -328,9 +328,9 @@ namespace Wabbajack.CLI.Verbs
|
||||
return header.Trim().Replace(" ", "").Replace(".", "");
|
||||
}
|
||||
|
||||
private static string GetModName(Archive a)
|
||||
private static string? GetModName(Archive a)
|
||||
{
|
||||
var result = a.Name;
|
||||
string? result = a.Name;
|
||||
|
||||
if (a.State is IMetaState metaState)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ namespace Wabbajack.CLI.Verbs
|
||||
public class DeleteFile : AVerb
|
||||
{
|
||||
[Option('n', "name", Required = true, HelpText = @"Full name (as returned by my-files) of the file")]
|
||||
public string? Name { get; set; }
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
protected override async Task<ExitCode> Run()
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ namespace Wabbajack.CLI.Verbs
|
||||
new[] {state}
|
||||
.PMap(queue, async s =>
|
||||
{
|
||||
await s.Download(new Archive {Name = Path.GetFileName(Output)}, (AbsolutePath)Output);
|
||||
await s.Download(new Archive(state: null!) {Name = Path.GetFileName(Output)}, (AbsolutePath)Output);
|
||||
}).Wait();
|
||||
|
||||
File.WriteAllLines(Output + ".meta", state.GetMetaIni());
|
||||
|
@ -11,7 +11,7 @@ namespace Wabbajack.Common.Http
|
||||
{
|
||||
public class Client
|
||||
{
|
||||
public List<(string, string)> Headers = new List<(string, string)>();
|
||||
public List<(string, string?)> Headers = new List<(string, string?)>();
|
||||
public List<Cookie> Cookies = new List<Cookie>();
|
||||
public async Task<HttpResponseMessage> GetAsync(string url, HttpCompletionOption responseHeadersRead = HttpCompletionOption.ResponseHeadersRead)
|
||||
{
|
||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Security;
|
||||
using DynamicData;
|
||||
using Microsoft.Win32;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Common.StoreHandlers
|
||||
{
|
||||
@ -21,9 +22,14 @@ namespace Wabbajack.Common.StoreHandlers
|
||||
|
||||
public class SteamWorkshopItem
|
||||
{
|
||||
public SteamGame? Game;
|
||||
public readonly SteamGame Game;
|
||||
public int ItemID;
|
||||
public int Size;
|
||||
|
||||
public SteamWorkshopItem(SteamGame game)
|
||||
{
|
||||
Game = game;
|
||||
}
|
||||
}
|
||||
|
||||
public class SteamHandler : AStoreHandler
|
||||
@ -202,14 +208,14 @@ namespace Wabbajack.Common.StoreHandlers
|
||||
var bracketStart = 0;
|
||||
var bracketEnd = 0;
|
||||
|
||||
SteamWorkshopItem? currentItem = new SteamWorkshopItem();
|
||||
SteamWorkshopItem? currentItem = new SteamWorkshopItem(game);
|
||||
|
||||
lines.Do(l =>
|
||||
{
|
||||
if (end)
|
||||
return;
|
||||
if (currentItem == null)
|
||||
currentItem = new SteamWorkshopItem();
|
||||
currentItem = new SteamWorkshopItem(game);
|
||||
|
||||
var currentLine = lines.IndexOf(l);
|
||||
if (l.ContainsCaseInsensitive("\"appid\"") && !foundAppID)
|
||||
@ -271,7 +277,6 @@ namespace Wabbajack.Common.StoreHandlers
|
||||
|
||||
bracketStart = 0;
|
||||
bracketEnd = 0;
|
||||
currentItem.Game = game;
|
||||
game.WorkshopItems.Add(currentItem);
|
||||
|
||||
Utils.Log($"Found Steam Workshop item {currentItem.ItemID}");
|
||||
|
@ -8,7 +8,6 @@ using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.StatusFeed;
|
||||
using Wabbajack.VirtualFileSystem;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
|
@ -14,7 +14,6 @@ using Wabbajack.VirtualFileSystem;
|
||||
using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
@ -243,10 +242,7 @@ namespace Wabbajack.Lib
|
||||
Error(
|
||||
$"No download metadata found for {archive.Name}, please use MO2 to query info or add a .meta file and try again.");
|
||||
|
||||
var result = new Archive
|
||||
{
|
||||
State = await DownloadDispatcher.ResolveArchive(archive.IniData)
|
||||
};
|
||||
var result = new Archive(await DownloadDispatcher.ResolveArchive(archive.IniData));
|
||||
|
||||
if (result.State == null)
|
||||
Error($"{archive.Name} could not be handled by any of the downloaders");
|
||||
|
@ -13,7 +13,6 @@ using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
@ -30,9 +29,9 @@ namespace Wabbajack.Lib
|
||||
public ModList ModList { get; private set; }
|
||||
public Dictionary<Hash, AbsolutePath> HashedArchives { get; } = new Dictionary<Hash, AbsolutePath>();
|
||||
|
||||
public SystemParameters SystemParameters { get; set; }
|
||||
public SystemParameters? SystemParameters { get; set; }
|
||||
|
||||
public AInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters parameters, int steps)
|
||||
public AInstaller(AbsolutePath archive, ModList modList, AbsolutePath outputFolder, AbsolutePath downloadFolder, SystemParameters? parameters, int steps)
|
||||
: base(steps)
|
||||
{
|
||||
ModList = modList;
|
||||
@ -168,6 +167,10 @@ namespace Wabbajack.Lib
|
||||
.PDoIndexed(queue, async (idx, group) =>
|
||||
{
|
||||
Utils.Status("Installing files", Percent.FactoryPutInRange(idx, vFiles.Count));
|
||||
if (group.Key == null)
|
||||
{
|
||||
throw new ArgumentNullException("FromFile was null");
|
||||
}
|
||||
var firstDest = OutputFolder.Combine(group.First().To);
|
||||
await CopyFile(group.Key.StagedPath, firstDest, true);
|
||||
|
||||
@ -175,7 +178,6 @@ namespace Wabbajack.Lib
|
||||
{
|
||||
await CopyFile(firstDest, OutputFolder.Combine(copy.To), false);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Status("Unstaging files");
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Exceptions;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Threading.Tasks;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.StatusFeed.Errors;
|
||||
using Wabbajack.VirtualFileSystem;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
@ -80,12 +79,12 @@ namespace Wabbajack.Lib.CompilationSteps
|
||||
CreateBSA directive;
|
||||
using (var bsa = BSADispatch.OpenRead(source.AbsolutePath))
|
||||
{
|
||||
directive = new CreateBSA
|
||||
directive = new CreateBSA(
|
||||
state: bsa.State,
|
||||
items: bsa.Files.Select(f => f.State).ToList())
|
||||
{
|
||||
To = source.Path,
|
||||
TempID = (RelativePath)id,
|
||||
State = bsa.State,
|
||||
FileStates = bsa.Files.Select(f => f.State).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Threading.Tasks;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -3,7 +3,6 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -6,7 +6,6 @@ using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.VirtualFileSystem;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.StoreHandlers;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -3,7 +3,6 @@ using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -3,7 +3,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.CompilationSteps
|
||||
{
|
||||
|
@ -43,22 +43,22 @@ namespace Wabbajack.Lib
|
||||
/// <summary>
|
||||
/// Archives required by this modlist
|
||||
/// </summary>
|
||||
public List<Archive> Archives;
|
||||
public List<Archive> Archives = new List<Archive>();
|
||||
|
||||
/// <summary>
|
||||
/// Author of the ModList
|
||||
/// </summary>
|
||||
public string Author;
|
||||
public string Author = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Description of the ModList
|
||||
/// </summary>
|
||||
public string Description;
|
||||
public string Description = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Install directives
|
||||
/// </summary>
|
||||
public List<Directive> Directives;
|
||||
public List<Directive> Directives = new List<Directive>();
|
||||
|
||||
/// <summary>
|
||||
/// The game variant to which this game applies
|
||||
@ -78,12 +78,12 @@ namespace Wabbajack.Lib
|
||||
/// <summary>
|
||||
/// Name of the ModList
|
||||
/// </summary>
|
||||
public string Name;
|
||||
public string Name = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// readme path or website
|
||||
/// </summary>
|
||||
public string Readme;
|
||||
public string Readme = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Whether readme is a website
|
||||
@ -93,12 +93,12 @@ namespace Wabbajack.Lib
|
||||
/// <summary>
|
||||
/// The build version of Wabbajack used when compiling the Modlist
|
||||
/// </summary>
|
||||
public Version WabbajackVersion;
|
||||
public Version? WabbajackVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Website of the ModList
|
||||
/// </summary>
|
||||
public Uri Website;
|
||||
public Uri? Website;
|
||||
|
||||
/// <summary>
|
||||
/// The size of all the archives once they're downloaded
|
||||
@ -134,7 +134,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
public class IgnoredDirectly : Directive
|
||||
{
|
||||
public string Reason;
|
||||
public string Reason = string.Empty;
|
||||
}
|
||||
|
||||
public class NoMatch : IgnoredDirectly
|
||||
@ -190,12 +190,12 @@ namespace Wabbajack.Lib
|
||||
[JsonName("FromArchive")]
|
||||
public class FromArchive : Directive
|
||||
{
|
||||
private string _fullPath;
|
||||
private string? _fullPath;
|
||||
|
||||
public HashRelativePath ArchiveHashPath { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public VirtualFile FromFile { get; set; }
|
||||
public VirtualFile? FromFile { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string FullPath => _fullPath ??= string.Join("|", ArchiveHashPath);
|
||||
@ -205,8 +205,17 @@ namespace Wabbajack.Lib
|
||||
public class CreateBSA : Directive
|
||||
{
|
||||
public RelativePath TempID { get; set; }
|
||||
public ArchiveStateObject State { get; set; }
|
||||
public List<FileStateObject> FileStates { get; set; }
|
||||
public ArchiveStateObject State { get; }
|
||||
public List<FileStateObject> FileStates { get; set; } = new List<FileStateObject>();
|
||||
|
||||
public CreateBSA(ArchiveStateObject state, IEnumerable<FileStateObject>? items = null)
|
||||
{
|
||||
State = state;
|
||||
if (items != null)
|
||||
{
|
||||
FileStates.AddRange(items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonName("PatchedFromArchive")]
|
||||
@ -231,7 +240,7 @@ namespace Wabbajack.Lib
|
||||
public class MergedPatch : Directive
|
||||
{
|
||||
public RelativePath PatchID { get; set; }
|
||||
public List<SourcePatch> Sources { get; set; }
|
||||
public List<SourcePatch> Sources { get; set; } = new List<SourcePatch>();
|
||||
}
|
||||
|
||||
[JsonName("Archive")]
|
||||
@ -245,49 +254,33 @@ namespace Wabbajack.Lib
|
||||
/// <summary>
|
||||
/// Meta INI for the downloaded archive
|
||||
/// </summary>
|
||||
public string Meta { get; set; }
|
||||
public string? Meta { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Human friendly name of this archive
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public long Size { get; set; }
|
||||
|
||||
public AbstractDownloadState State { get; set; }
|
||||
public AbstractDownloadState State { get; }
|
||||
|
||||
public Archive(AbstractDownloadState state)
|
||||
{
|
||||
State = state;
|
||||
}
|
||||
}
|
||||
|
||||
public class IndexedArchive
|
||||
{
|
||||
public dynamic IniData;
|
||||
public string Meta;
|
||||
public string Name;
|
||||
public VirtualFile File { get; internal set; }
|
||||
}
|
||||
public dynamic? IniData;
|
||||
public string Meta = string.Empty;
|
||||
public string Name = string.Empty;
|
||||
public VirtualFile File { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A archive entry
|
||||
/// </summary>
|
||||
public class IndexedEntry
|
||||
public IndexedArchive(VirtualFile file)
|
||||
{
|
||||
/// <summary>
|
||||
/// MurMur3 hash of this file
|
||||
/// </summary>
|
||||
public string Hash;
|
||||
|
||||
/// <summary>
|
||||
/// Path in the archive to this file
|
||||
/// </summary>
|
||||
public string Path;
|
||||
|
||||
/// <summary>
|
||||
/// Size of the file (uncompressed)
|
||||
/// </summary>
|
||||
public long Size;
|
||||
File = file;
|
||||
}
|
||||
|
||||
public class IndexedArchiveEntry : IndexedEntry
|
||||
{
|
||||
public string[] HashPath;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Validation;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
@ -84,7 +83,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
public async Task<bool> Download(AbsolutePath destination)
|
||||
{
|
||||
destination.Parent.CreateDirectory();
|
||||
return await Download(new Archive {Name = (string)destination.FileName}, destination);
|
||||
// ToDo
|
||||
// Is this null override needed? Why is state allowed to be null here?
|
||||
return await Download(new Archive(state: null!) {Name = (string)destination.FileName}, destination);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -8,7 +8,6 @@ using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Validation;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -21,7 +21,17 @@ namespace Wabbajack.Lib.Downloaders
|
||||
private readonly string _encryptedKeyName;
|
||||
private readonly string _cookieDomain;
|
||||
private readonly string _cookieName;
|
||||
internal Common.Http.Client AuthedClient;
|
||||
// ToDo
|
||||
// Remove null assignment. Either add nullability to type, or figure way to prepare it safely
|
||||
public Common.Http.Client AuthedClient { get; private set; } = null!;
|
||||
|
||||
public ReactiveCommand<Unit, Unit> TriggerLogin { get; }
|
||||
public ReactiveCommand<Unit, Unit> ClearLogin { get; }
|
||||
public IObservable<bool> IsLoggedIn => Utils.HaveEncryptedJsonObservable(_encryptedKeyName);
|
||||
public abstract string SiteName { get; }
|
||||
public virtual IObservable<string>? MetaInfo { get; }
|
||||
public abstract Uri SiteURL { get; }
|
||||
public virtual Uri? IconUri { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets up all the login facilites needed for a INeedsLogin downloader based on having the user log
|
||||
@ -49,14 +59,6 @@ namespace Wabbajack.Lib.Downloaders
|
||||
canExecute: IsLoggedIn.ObserveOnGuiThread());
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> TriggerLogin { get; }
|
||||
public ReactiveCommand<Unit, Unit> ClearLogin { get; }
|
||||
public IObservable<bool> IsLoggedIn => Utils.HaveEncryptedJsonObservable(_encryptedKeyName);
|
||||
public abstract string SiteName { get; }
|
||||
public virtual IObservable<string> MetaInfo { get; }
|
||||
public abstract Uri SiteURL { get; }
|
||||
public virtual Uri IconUri { get; }
|
||||
|
||||
protected virtual async Task WhileWaiting(IWebDriver browser)
|
||||
{
|
||||
}
|
||||
@ -120,7 +122,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
Downloader = downloader;
|
||||
}
|
||||
public override string ShortDescription => $"Getting {Downloader.SiteName} Login";
|
||||
public override string ExtendedDescription { get; }
|
||||
public override string ExtendedDescription { get; } = string.Empty;
|
||||
|
||||
private readonly TaskCompletionSource<Helpers.Cookie[]> _source = new TaskCompletionSource<Helpers.Cookie[]>();
|
||||
public Task<Helpers.Cookie[]> Task => _source.Task;
|
||||
|
@ -24,7 +24,6 @@ using Wabbajack.Lib.Validation;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using Game = Wabbajack.Common.Game;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
IndexedDownloaders = Downloaders.ToDictionary(d => d.GetType());
|
||||
}
|
||||
|
||||
public static async Task<AbstractDownloadState> Infer(Uri uri)
|
||||
public static async Task<AbstractDownloadState?> Infer(Uri uri)
|
||||
{
|
||||
foreach (var inf in Inferencers)
|
||||
{
|
||||
@ -74,7 +74,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
/// </summary>
|
||||
/// <param name="ini"></param>
|
||||
/// <returns></returns>
|
||||
public static AbstractDownloadState ResolveArchive(string url)
|
||||
public static AbstractDownloadState? ResolveArchive(string url)
|
||||
{
|
||||
return Downloaders.OfType<IUrlDownloader>().Select(d => d.GetDownloaderState(url)).FirstOrDefault(result => result != null);
|
||||
}
|
||||
@ -112,10 +112,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
var patchName = $"{archive.Hash.ToHex()}_{upgrade.Hash.ToHex()}";
|
||||
var patchPath = destination.Parent.Combine("_Patch_" + patchName);
|
||||
|
||||
var patchState = new Archive
|
||||
var patchState = new Archive(new HTTPDownloader.State($"https://wabbajackcdn.b-cdn.net/updates/{patchName}"))
|
||||
{
|
||||
Name = patchName,
|
||||
State = new HTTPDownloader.State($"https://wabbajackcdn.b-cdn.net/updates/{patchName}")
|
||||
};
|
||||
|
||||
var patchResult = await Download(patchState, patchPath);
|
||||
|
@ -4,7 +4,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
public static class DownloaderUtils
|
||||
{
|
||||
public static Uri GetDirectURL(dynamic meta)
|
||||
public static Uri? GetDirectURL(dynamic? meta)
|
||||
{
|
||||
var url = meta?.General?.directURL;
|
||||
if (url == null) return null;
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ using Wabbajack.Common;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Game = Wabbajack.Common.Game;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ using Wabbajack.Common;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
using Wabbajack.Lib.Exceptions;
|
||||
using Wabbajack.Lib.Validation;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -10,7 +10,6 @@ using Wabbajack.Common;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
using Wabbajack.Lib.Exceptions;
|
||||
using Wabbajack.Lib.Validation;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Threading.Tasks;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.Reactive;
|
||||
using System.Security;
|
||||
using ReactiveUI;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
@ -12,7 +11,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
ReactiveCommand<Unit, Unit> ClearLogin { get; }
|
||||
IObservable<bool> IsLoggedIn { get; }
|
||||
string SiteName { get; }
|
||||
IObservable<string> MetaInfo { get; }
|
||||
IObservable<string>? MetaInfo { get; }
|
||||
Uri SiteURL { get; }
|
||||
Uri? IconUri { get; }
|
||||
}
|
||||
|
@ -2,6 +2,6 @@
|
||||
{
|
||||
public interface IUrlDownloader : IDownloader
|
||||
{
|
||||
AbstractDownloadState GetDownloaderState(string url);
|
||||
AbstractDownloadState? GetDownloaderState(string url);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
using Wabbajack.Lib.WebAutomation;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ using Newtonsoft.Json;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -6,7 +6,6 @@ using Wabbajack.Common;
|
||||
using Wabbajack.Common.IO;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
using Wabbajack.Lib.Validation;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Wabbajack.Lib.WebAutomation;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -6,7 +6,6 @@ using Newtonsoft.Json;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
using Wabbajack.Lib.Validation;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -12,7 +12,6 @@ using Wabbajack.Common.StatusFeed.Errors;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Game = Wabbajack.Common.Game;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -14,20 +14,21 @@ namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
public class SteamWorkshopDownloader : IUrlDownloader
|
||||
{
|
||||
private SteamWorkshopItem _item;
|
||||
|
||||
public async Task<AbstractDownloadState> GetDownloaderState(dynamic archiveINI, bool quickMode)
|
||||
public async Task<AbstractDownloadState?> GetDownloaderState(dynamic archiveINI, bool quickMode)
|
||||
{
|
||||
var id = archiveINI?.General?.itemID;
|
||||
var steamID = archiveINI?.General?.steamID;
|
||||
var size = archiveINI?.General?.itemSize;
|
||||
_item = new SteamWorkshopItem
|
||||
if (steamID == null)
|
||||
{
|
||||
throw new ArgumentException("Steam workshop item had no steam ID.");
|
||||
}
|
||||
var item = new SteamWorkshopItem(GameRegistry.GetBySteamID(int.Parse(steamID)))
|
||||
{
|
||||
ItemID = id != null ? int.Parse(id) : 0,
|
||||
Size = size != null ? int.Parse(size) : 0,
|
||||
Game = steamID != null ? GameRegistry.GetBySteamID(int.Parse(steamID)) : null
|
||||
};
|
||||
return new State {Item = _item};
|
||||
return new State(item);
|
||||
}
|
||||
|
||||
public async Task Prepare()
|
||||
@ -41,8 +42,14 @@ namespace Wabbajack.Lib.Downloaders
|
||||
|
||||
public class State : AbstractDownloadState
|
||||
{
|
||||
public SteamWorkshopItem Item { get; set; }
|
||||
public override object[] PrimaryKey { get => new object[] {Item.Game, Item.ItemID}; }
|
||||
public SteamWorkshopItem Item { get; }
|
||||
|
||||
public override object[] PrimaryKey => new object[] { Item.Game, Item.ItemID };
|
||||
|
||||
public State(SteamWorkshopItem item)
|
||||
{
|
||||
Item = item;
|
||||
}
|
||||
|
||||
public override bool IsWhitelisted(ServerWhitelist whitelist)
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders.UrlDownloaders
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders.UrlDownloaders
|
||||
{
|
||||
|
@ -3,7 +3,6 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
using YoutubeExplode;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders.UrlDownloaders
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -15,7 +15,6 @@ using YoutubeExplode.Exceptions;
|
||||
using YoutubeExplode.Models.MediaStreams;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
|
@ -12,6 +12,5 @@ namespace Wabbajack.Lib.Exceptions
|
||||
Code = code;
|
||||
Reason = reason;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ namespace Wabbajack.Lib.FileUploader
|
||||
{
|
||||
public static IObservable<bool> HaveAuthorAPIKey => Utils.HaveEncryptedJsonObservable(Consts.AuthorAPIKeyFile);
|
||||
|
||||
public static string ApiKeyOverride = null;
|
||||
public static string? ApiKeyOverride = null;
|
||||
|
||||
public static async Task<string> GetAPIKey(string apiKey = null)
|
||||
public static async Task<string> GetAPIKey(string? apiKey = null)
|
||||
{
|
||||
if (ApiKeyOverride != null) return ApiKeyOverride;
|
||||
return apiKey ?? (await Consts.LocalAppDataPath.Combine(Consts.AuthorAPIKeyFile).ReadAllTextAsync()).Trim();
|
||||
@ -32,7 +32,7 @@ namespace Wabbajack.Lib.FileUploader
|
||||
public static Uri UploadURL => new Uri($"{Consts.WabbajackBuildServerUri}upload_file");
|
||||
public static long BLOCK_SIZE = (long)1024 * 1024 * 2;
|
||||
public static int MAX_CONNECTIONS = 8;
|
||||
public static Task<string> UploadFile(AbsolutePath filename, Action<double> progressFn, string apikey=null)
|
||||
public static Task<string> UploadFile(AbsolutePath filename, Action<double> progressFn, string? apikey = null)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
Task.Run(async () =>
|
||||
@ -123,7 +123,7 @@ namespace Wabbajack.Lib.FileUploader
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public static async Task<Common.Http.Client> GetAuthorizedClient(string apiKey=null)
|
||||
public static async Task<Common.Http.Client> GetAuthorizedClient(string? apiKey = null)
|
||||
{
|
||||
var client = new Common.Http.Client();
|
||||
client.Headers.Add(("X-API-KEY", await GetAPIKey(apiKey)));
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
|
@ -78,10 +78,10 @@ namespace Wabbajack.Lib.LibCefHelpers
|
||||
[JsonName("HttpCookie")]
|
||||
public class Cookie
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string Domain { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Value { get; set; } = string.Empty;
|
||||
public string Domain { get; set; } = string.Empty;
|
||||
public string Path { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
|
@ -20,7 +20,6 @@ using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;
|
||||
using Game = Wabbajack.Common.Game;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
@ -175,9 +174,8 @@ namespace Wabbajack.Lib
|
||||
|
||||
IndexedArchives = (await MO2DownloadsFolder.EnumerateFiles()
|
||||
.Where(f => f.WithExtension(Consts.MetaFileExtension).Exists)
|
||||
.PMap(Queue, async f => new IndexedArchive
|
||||
.PMap(Queue, async f => new IndexedArchive(VFS.Index.ByRootPath[f])
|
||||
{
|
||||
File = VFS.Index.ByRootPath[f],
|
||||
Name = (string)f.FileName,
|
||||
IniData = f.WithExtension(Consts.MetaFileExtension).LoadIniFile(),
|
||||
Meta = await f.WithExtension(Consts.MetaFileExtension).ReadAllTextAsync()
|
||||
|
@ -21,7 +21,6 @@ using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
using SectionData = Wabbajack.Common.SectionData;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
@ -332,6 +331,10 @@ namespace Wabbajack.Lib
|
||||
|
||||
private void SetScreenSizeInPrefs()
|
||||
{
|
||||
if (SystemParameters == null)
|
||||
{
|
||||
throw new ArgumentNullException("System Parameters was null. Cannot set screen size prefs");
|
||||
}
|
||||
var config = new IniParserConfiguration {AllowDuplicateKeys = true, AllowDuplicateSections = true};
|
||||
foreach (var file in OutputFolder.Combine("profiles").EnumerateFiles()
|
||||
.Where(f => ((string)f.FileName).EndsWith("refs.ini")))
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
@ -42,12 +41,11 @@ namespace Wabbajack.Lib
|
||||
InstallSize = modlist.InstallSize;
|
||||
|
||||
// meta is being omitted due to it being useless and not very space friendly
|
||||
Archives = modlist.Archives.Select(a => new Archive
|
||||
Archives = modlist.Archives.Select(a => new Archive(a.State)
|
||||
{
|
||||
Hash = a.Hash,
|
||||
Name = a.Name,
|
||||
Size = a.Size,
|
||||
State = a.State
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
@ -13,13 +13,13 @@ namespace Wabbajack.Lib.ModListRegistry
|
||||
public class ModlistMetadata
|
||||
{
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("author")]
|
||||
public string Author { get; set; }
|
||||
public string Author { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("game")]
|
||||
public Game Game { get; set; }
|
||||
@ -33,7 +33,7 @@ namespace Wabbajack.Lib.ModListRegistry
|
||||
public LinksObject Links { get; set; } = new LinksObject();
|
||||
|
||||
[JsonProperty("download_metadata")]
|
||||
public DownloadMetadata DownloadMetadata { get; set; }
|
||||
public DownloadMetadata? DownloadMetadata { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public ModListSummary ValidationSummary { get; set; } = new ModListSummary();
|
||||
@ -42,22 +42,18 @@ namespace Wabbajack.Lib.ModListRegistry
|
||||
public class LinksObject
|
||||
{
|
||||
[JsonProperty("image")]
|
||||
public string ImageUri { get; set; }
|
||||
public string ImageUri { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("readme")]
|
||||
public string Readme { get; set; }
|
||||
public string Readme { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("download")]
|
||||
public string Download { get; set; }
|
||||
public string Download { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("machineURL")]
|
||||
public string MachineURL { get; set; }
|
||||
public string MachineURL { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static async Task<List<ModlistMetadata>> LoadFromGithub()
|
||||
{
|
||||
var client = new Common.Http.Client();
|
||||
@ -103,17 +99,16 @@ namespace Wabbajack.Lib.ModListRegistry
|
||||
public long SizeOfArchives { get; set; }
|
||||
public long NumberOfInstalledFiles { get; set; }
|
||||
public long SizeOfInstalledFiles { get; set; }
|
||||
|
||||
}
|
||||
|
||||
[JsonName("ModListSummary")]
|
||||
public class ModListSummary
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("machineURL")]
|
||||
public string MachineURL { get; set; }
|
||||
public string MachineURL { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("checked")]
|
||||
public DateTime Checked { get; set; }
|
||||
|
@ -4,57 +4,57 @@ namespace Wabbajack.Lib.NexusApi
|
||||
{
|
||||
public class UserStatus
|
||||
{
|
||||
public string email;
|
||||
public string email = string.Empty;
|
||||
public bool is_premium;
|
||||
public bool is_supporter;
|
||||
public string key;
|
||||
public string name;
|
||||
public string profile_url;
|
||||
public string user_id;
|
||||
public string key = string.Empty;
|
||||
public string name = string.Empty;
|
||||
public string profile_url = string.Empty;
|
||||
public string user_id = string.Empty;
|
||||
}
|
||||
|
||||
public class NexusFileInfo
|
||||
{
|
||||
public long category_id { get; set; }
|
||||
public string category_name { get; set; }
|
||||
public string changelog_html { get; set; }
|
||||
public string description { get; set; }
|
||||
public string external_virus_scan_url { get; set; }
|
||||
public string category_name { get; set; } = string.Empty;
|
||||
public string changelog_html { get; set; } = string.Empty;
|
||||
public string description { get; set; } = string.Empty;
|
||||
public string external_virus_scan_url { get; set; } = string.Empty;
|
||||
public long file_id { get; set; }
|
||||
public string file_name { get; set; }
|
||||
public string file_name { get; set; } = string.Empty;
|
||||
public bool is_primary { get; set; }
|
||||
public string mod_version { get; set; }
|
||||
public string name { get; set; }
|
||||
public string mod_version { get; set; } = string.Empty;
|
||||
public string name { get; set; } = string.Empty;
|
||||
public long size { get; set; }
|
||||
public long size_kb { get; set; }
|
||||
public DateTime uploaded_time { get; set; }
|
||||
public long uploaded_timestamp { get; set; }
|
||||
public string version { get; set; }
|
||||
public string version { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class ModInfo
|
||||
{
|
||||
public uint _internal_version { get; set; }
|
||||
public string game_name { get; set; }
|
||||
public string mod_id { get; set; }
|
||||
public string name { get; set; }
|
||||
public string summary { get; set; }
|
||||
public string author { get; set; }
|
||||
public string uploaded_by { get; set; }
|
||||
public string uploaded_users_profile_url { get; set; }
|
||||
public string picture_url { get; set; }
|
||||
public string game_name { get; set; } = string.Empty;
|
||||
public string mod_id { get; set; } = string.Empty;
|
||||
public string name { get; set; } = string.Empty;
|
||||
public string summary { get; set; } = string.Empty;
|
||||
public string author { get; set; } = string.Empty;
|
||||
public string uploaded_by { get; set; } = string.Empty;
|
||||
public string uploaded_users_profile_url { get; set; } = string.Empty;
|
||||
public string picture_url { get; set; } = string.Empty;
|
||||
public bool contains_adult_content { get; set; }
|
||||
}
|
||||
|
||||
public class MD5Response
|
||||
{
|
||||
public ModInfo mod;
|
||||
public NexusFileInfo file_details;
|
||||
public ModInfo? mod;
|
||||
public NexusFileInfo? file_details;
|
||||
}
|
||||
|
||||
public class EndorsementResponse
|
||||
{
|
||||
public string message;
|
||||
public string status;
|
||||
public string message = string.Empty;
|
||||
public string status = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +27,11 @@ namespace Wabbajack.Lib.NexusApi
|
||||
|
||||
#region Authentication
|
||||
|
||||
public string ApiKey { get; }
|
||||
public string? ApiKey { get; }
|
||||
|
||||
public bool IsAuthenticated => ApiKey != null;
|
||||
|
||||
private Task<UserStatus> _userStatus;
|
||||
|
||||
private Task<UserStatus>? _userStatus;
|
||||
public Task<UserStatus> UserStatus
|
||||
{
|
||||
get
|
||||
@ -214,7 +213,7 @@ namespace Wabbajack.Lib.NexusApi
|
||||
|
||||
#endregion
|
||||
|
||||
private NexusApiClient(string apiKey = null)
|
||||
private NexusApiClient(string? apiKey = null)
|
||||
{
|
||||
ApiKey = apiKey;
|
||||
|
||||
@ -230,9 +229,9 @@ namespace Wabbajack.Lib.NexusApi
|
||||
Directory.CreateDirectory(Consts.NexusCacheDirectory);
|
||||
}
|
||||
|
||||
public static async Task<NexusApiClient> Get(string apiKey = null)
|
||||
public static async Task<NexusApiClient> Get(string? apiKey = null)
|
||||
{
|
||||
apiKey = apiKey ?? await GetApiKey();
|
||||
apiKey ??= await GetApiKey();
|
||||
return new NexusApiClient(apiKey);
|
||||
}
|
||||
|
||||
@ -316,9 +315,10 @@ namespace Wabbajack.Lib.NexusApi
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public class GetModFilesResponse
|
||||
{
|
||||
public List<NexusFileInfo> files { get; set; }
|
||||
public List<NexusFileInfo> files { get; set; } = new List<NexusFileInfo>();
|
||||
}
|
||||
|
||||
public async Task<GetModFilesResponse> GetModFiles(Game game, long modid)
|
||||
@ -344,18 +344,18 @@ namespace Wabbajack.Lib.NexusApi
|
||||
|
||||
private class DownloadLink
|
||||
{
|
||||
public string URI { get; set; }
|
||||
public string URI { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public static MethodInfo CacheMethod { get; set; }
|
||||
|
||||
private static string _localCacheDir;
|
||||
private static string? _localCacheDir;
|
||||
public static string LocalCacheDir
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_localCacheDir == null)
|
||||
_localCacheDir = Environment.GetEnvironmentVariable("NEXUSCACHEDIR");
|
||||
if (_localCacheDir == null)
|
||||
throw new ArgumentNullException($"Enviornment variable could not be located: NEXUSCACHEDIR");
|
||||
return _localCacheDir;
|
||||
}
|
||||
set => _localCacheDir = value;
|
||||
|
@ -18,16 +18,11 @@ namespace Wabbajack.Lib.NexusApi
|
||||
}
|
||||
|
||||
public static string FixupSummary(string argSummary)
|
||||
{
|
||||
if (argSummary != null)
|
||||
{
|
||||
return argSummary.Replace("'", "'")
|
||||
.Replace("<br/>", "\n\n")
|
||||
.Replace("<br />", "\n\n")
|
||||
.Replace("!", "!");
|
||||
}
|
||||
|
||||
return argSummary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace Wabbajack.Lib.NexusApi
|
||||
public class RequestNexusAuthorization : AUserIntervention
|
||||
{
|
||||
public override string ShortDescription => "Getting User's Nexus API Key";
|
||||
public override string ExtendedDescription { get; }
|
||||
public override string ExtendedDescription { get; } = string.Empty;
|
||||
|
||||
private readonly TaskCompletionSource<string> _source = new TaskCompletionSource<string>();
|
||||
public Task<string> Task => _source.Task;
|
||||
|
@ -10,7 +10,7 @@ namespace Wabbajack.Lib
|
||||
public class ConfirmUpdateOfExistingInstall : ConfirmationIntervention
|
||||
{
|
||||
public AbsolutePath OutputFolder { get; set; }
|
||||
public string ModListName { get; set; }
|
||||
public string ModListName { get; set; } = string.Empty;
|
||||
|
||||
public override string ShortDescription { get; } = "Do you want to overwrite existing files?";
|
||||
|
||||
|
@ -9,8 +9,8 @@ namespace Wabbajack.Lib
|
||||
public class ManuallyDownloadFile : AUserIntervention
|
||||
{
|
||||
public ManualDownloader.State State { get; }
|
||||
public override string ShortDescription { get; }
|
||||
public override string ExtendedDescription { get; }
|
||||
public override string ShortDescription { get; } = string.Empty;
|
||||
public override string ExtendedDescription { get; } = string.Empty;
|
||||
|
||||
private TaskCompletionSource<(Uri, Common.Http.Client)> _tcs = new TaskCompletionSource<(Uri, Common.Http.Client)>();
|
||||
public Task<(Uri, Common.Http.Client)> Task => _tcs.Task;
|
||||
|
@ -9,8 +9,8 @@ namespace Wabbajack.Lib
|
||||
public class ManuallyDownloadNexusFile : AUserIntervention
|
||||
{
|
||||
public NexusDownloader.State State { get; }
|
||||
public override string ShortDescription { get; }
|
||||
public override string ExtendedDescription { get; }
|
||||
public override string ShortDescription { get; } = string.Empty;
|
||||
public override string ExtendedDescription { get; } = string.Empty;
|
||||
|
||||
private TaskCompletionSource<Uri> _tcs = new TaskCompletionSource<Uri>();
|
||||
public Task<Uri> Task => _tcs.Task;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
|
@ -10,33 +10,32 @@ namespace Wabbajack.Lib.Validation
|
||||
public bool? CanUseInOtherGames { get; set; }
|
||||
}
|
||||
|
||||
public class Author
|
||||
{
|
||||
public Permissions Permissions { get; set; }
|
||||
public Dictionary<string, Game> Games;
|
||||
}
|
||||
//public class Author
|
||||
//{
|
||||
// public Permissions Permissions { get; set; }
|
||||
// public Dictionary<string, Game> Games;
|
||||
//}
|
||||
|
||||
public class Game
|
||||
{
|
||||
public Permissions Permissions;
|
||||
public Dictionary<string, Mod> Mods;
|
||||
}
|
||||
//public class Game
|
||||
//{
|
||||
// public Permissions Permissions;
|
||||
// public Dictionary<string, Mod> Mods;
|
||||
//}
|
||||
|
||||
public class Mod
|
||||
{
|
||||
public Permissions Permissions;
|
||||
public Dictionary<string, File> Files;
|
||||
}
|
||||
|
||||
public class File
|
||||
{
|
||||
public Permissions Permissions;
|
||||
}
|
||||
//public class Mod
|
||||
//{
|
||||
// public Permissions Permissions;
|
||||
// public Dictionary<string, File> Files;
|
||||
//}
|
||||
|
||||
//public class File
|
||||
//{
|
||||
// public Permissions Permissions;
|
||||
//}
|
||||
|
||||
public class ServerWhitelist
|
||||
{
|
||||
public List<string> GoogleIDs;
|
||||
public List<string> AllowedPrefixes;
|
||||
public List<string> GoogleIDs = new List<string>();
|
||||
public List<string> AllowedPrefixes = new List<string>();
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Runtime.CompilerServices;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
|
@ -15,7 +15,6 @@ using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using Game = Wabbajack.Common.Game;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Platforms>x64</Platforms>
|
||||
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CefSharp.Common">
|
||||
|
@ -13,8 +13,8 @@ namespace Wabbajack.Lib.WebAutomation
|
||||
{
|
||||
public class CefSharpWrapper : IWebDriver
|
||||
{
|
||||
private IWebBrowser _browser;
|
||||
public Action<Uri> DownloadHandler { get; set; }
|
||||
private readonly IWebBrowser _browser;
|
||||
public Action<Uri>? DownloadHandler { get; set; }
|
||||
public CefSharpWrapper(IWebBrowser browser)
|
||||
{
|
||||
_browser = browser;
|
||||
@ -24,7 +24,7 @@ namespace Wabbajack.Lib.WebAutomation
|
||||
{
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
EventHandler<LoadingStateChangedEventArgs> handler = null;
|
||||
EventHandler<LoadingStateChangedEventArgs>? handler = null;
|
||||
handler = (sender, e) =>
|
||||
{
|
||||
if (!e.IsLoading)
|
||||
@ -68,7 +68,7 @@ namespace Wabbajack.Lib.WebAutomation
|
||||
|
||||
public class PopupBlocker : ILifeSpanHandler
|
||||
{
|
||||
private CefSharpWrapper _wrapper;
|
||||
private readonly CefSharpWrapper _wrapper;
|
||||
|
||||
public PopupBlocker(CefSharpWrapper cefSharpWrapper)
|
||||
{
|
||||
@ -77,7 +77,7 @@ namespace Wabbajack.Lib.WebAutomation
|
||||
|
||||
public bool OnBeforePopup(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl,
|
||||
string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures,
|
||||
IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
|
||||
IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser? newBrowser)
|
||||
{
|
||||
// Block popups
|
||||
newBrowser = null;
|
||||
@ -86,7 +86,6 @@ namespace Wabbajack.Lib.WebAutomation
|
||||
|
||||
public void OnAfterCreated(IWebBrowser chromiumWebBrowser, IBrowser browser)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool DoClose(IWebBrowser chromiumWebBrowser, IBrowser browser)
|
||||
@ -96,7 +95,6 @@ namespace Wabbajack.Lib.WebAutomation
|
||||
|
||||
public void OnBeforeClose(IWebBrowser chromiumWebBrowser, IBrowser browser)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +110,7 @@ namespace Wabbajack.Lib.WebAutomation
|
||||
public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem,
|
||||
IBeforeDownloadCallback callback)
|
||||
{
|
||||
_wrapper.DownloadHandler(new Uri(downloadItem.Url));
|
||||
_wrapper.DownloadHandler?.Invoke(new Uri(downloadItem.Url));
|
||||
}
|
||||
|
||||
public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem,
|
||||
|
@ -13,6 +13,6 @@ namespace Wabbajack.Lib.WebAutomation
|
||||
Task NavigateTo(Uri uri);
|
||||
Task<string> EvaluateJavaScript(string text);
|
||||
Task<Helpers.Cookie[]> GetCookies(string domainPrefix);
|
||||
public Action<Uri> DownloadHandler { get; set; }
|
||||
public Action<Uri>? DownloadHandler { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ namespace Wabbajack.Lib.WebAutomation
|
||||
return driver;
|
||||
}
|
||||
|
||||
public async Task<Uri> NavigateTo(Uri uri)
|
||||
public async Task<Uri?> NavigateTo(Uri uri)
|
||||
{
|
||||
await _driver.NavigateTo(uri);
|
||||
return await GetLocation();
|
||||
}
|
||||
|
||||
public async ValueTask<Uri> GetLocation()
|
||||
public async ValueTask<Uri?> GetLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -9,7 +9,6 @@ using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
using System.Threading.Tasks;
|
||||
#nullable enable
|
||||
|
||||
namespace Wabbajack.Lib
|
||||
{
|
||||
@ -151,7 +150,7 @@ namespace Wabbajack.Lib
|
||||
return inline;
|
||||
}
|
||||
var result = source.EvolveTo<MergedPatch>();
|
||||
result.Sources = merge.plugins.Select(f =>
|
||||
result.Sources.SetTo(merge.plugins.Select(f =>
|
||||
{
|
||||
var origPath = (AbsolutePath)Path.Combine(f.dataFolder, f.filename);
|
||||
var paths = new[]
|
||||
@ -172,10 +171,11 @@ namespace Wabbajack.Lib
|
||||
try
|
||||
{
|
||||
hash = _compiler.VFS.Index.ByRootPath[absPath].Hash;
|
||||
} catch (KeyNotFoundException e)
|
||||
}
|
||||
catch (KeyNotFoundException e)
|
||||
{
|
||||
Utils.ErrorThrow(e, $"Could not find the key {absPath} in the VFS Index dictionary!");
|
||||
return null;
|
||||
Utils.Error(e, $"Could not find the key {absPath} in the VFS Index dictionary!");
|
||||
throw;
|
||||
}
|
||||
|
||||
return new SourcePatch
|
||||
@ -183,7 +183,7 @@ namespace Wabbajack.Lib
|
||||
RelativePath = absPath.RelativeTo(_mo2Compiler.MO2Folder),
|
||||
Hash = hash
|
||||
};
|
||||
}).ToList();
|
||||
}));
|
||||
|
||||
var srcData = result.Sources.Select(f => _mo2Compiler.MO2Folder.Combine(f.RelativePath).ReadAllBytes())
|
||||
.ConcatArrays();
|
||||
|
@ -48,15 +48,15 @@ namespace Wabbajack.Test
|
||||
GameType = Game.Skyrim,
|
||||
Archives = new List<Archive>
|
||||
{
|
||||
new Archive
|
||||
{
|
||||
State = new NexusDownloader.State
|
||||
new Archive(
|
||||
new NexusDownloader.State
|
||||
{
|
||||
Game = Game.Skyrim,
|
||||
Author = "bill",
|
||||
ModID = 42,
|
||||
FileID = 33,
|
||||
},
|
||||
})
|
||||
{
|
||||
Hash = Hash.FromLong(42)
|
||||
}
|
||||
},
|
||||
@ -71,9 +71,8 @@ namespace Wabbajack.Test
|
||||
};
|
||||
// Error due to file downloaded from 3rd party
|
||||
modlist.GameType = Game.Skyrim;
|
||||
modlist.Archives[0] = new Archive()
|
||||
modlist.Archives[0] = new Archive(new HTTPDownloader.State("https://somebadplace.com"))
|
||||
{
|
||||
State = new HTTPDownloader.State("https://somebadplace.com"),
|
||||
Hash = Hash.FromLong(42)
|
||||
};
|
||||
var errors = await validate.Validate(modlist);
|
||||
@ -81,9 +80,8 @@ namespace Wabbajack.Test
|
||||
|
||||
// Ok due to file downloaded from whitelisted 3rd party
|
||||
modlist.GameType = Game.Skyrim;
|
||||
modlist.Archives[0] = new Archive
|
||||
modlist.Archives[0] = new Archive(new HTTPDownloader.State("https://somegoodplace.com/baz.7z"))
|
||||
{
|
||||
State = new HTTPDownloader.State("https://somegoodplace.com/baz.7z"),
|
||||
Hash = Hash.FromLong(42)
|
||||
};
|
||||
errors = await validate.Validate(modlist);
|
||||
@ -92,9 +90,8 @@ namespace Wabbajack.Test
|
||||
|
||||
// Error due to file downloaded from bad 3rd party
|
||||
modlist.GameType = Game.Skyrim;
|
||||
modlist.Archives[0] = new Archive
|
||||
modlist.Archives[0] = new Archive(new GoogleDriveDownloader.State("bleg"))
|
||||
{
|
||||
State = new GoogleDriveDownloader.State("bleg"),
|
||||
Hash = Hash.FromLong(42)
|
||||
};
|
||||
errors = await validate.Validate(modlist);
|
||||
@ -102,9 +99,8 @@ namespace Wabbajack.Test
|
||||
|
||||
// Ok due to file downloaded from good google site
|
||||
modlist.GameType = Game.Skyrim;
|
||||
modlist.Archives[0] = new Archive
|
||||
modlist.Archives[0] = new Archive(new GoogleDriveDownloader.State("googleDEADBEEF"))
|
||||
{
|
||||
State = new GoogleDriveDownloader.State("googleDEADBEEF"),
|
||||
Hash = Hash.FromLong(42)
|
||||
};
|
||||
errors = await validate.Validate(modlist);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user