mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
reworked 7z intergration, validate nexus archives during compilation
This commit is contained in:
parent
e8f2ad2f16
commit
687b920c85
@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SevenZipExtractor
|
||||
@ -262,8 +264,13 @@ namespace SevenZipExtractor
|
||||
return result;
|
||||
}
|
||||
|
||||
private static object _lockobj = new object();
|
||||
private static string _staticLibraryFilePath;
|
||||
|
||||
private void InitializeAndValidateLibrary()
|
||||
{
|
||||
this.libraryFilePath = SetupLibrary();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(this.libraryFilePath))
|
||||
{
|
||||
string currentArchitecture = IntPtr.Size == 4 ? "x86" : "x64"; // magic check
|
||||
@ -306,6 +313,28 @@ namespace SevenZipExtractor
|
||||
}
|
||||
}
|
||||
|
||||
private static string SetupLibrary()
|
||||
{
|
||||
var zpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "7z-x64.dll");
|
||||
if (_staticLibraryFilePath == null)
|
||||
{
|
||||
lock (_lockobj)
|
||||
{
|
||||
if (_staticLibraryFilePath == null)
|
||||
{
|
||||
using (var s = Assembly.GetExecutingAssembly().GetManifestResourceStream("SevenZipExtractor.7z.dll.gz"))
|
||||
using (var fs = File.OpenWrite(zpath))
|
||||
using (var gz = new GZipStream(s, CompressionMode.Decompress))
|
||||
{
|
||||
gz.CopyTo(fs);
|
||||
}
|
||||
_staticLibraryFilePath = zpath;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _staticLibraryFilePath;
|
||||
}
|
||||
|
||||
private bool GuessFormatFromExtension(string fileExtension, out SevenZipFormat format)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(fileExtension))
|
||||
|
@ -56,6 +56,7 @@
|
||||
<Compile Include="SevenZipInterface.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="7z.dll.gz" />
|
||||
<None Include="SevenZipExtractor.nuspec">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
@ -14,6 +14,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Wabbajack.Common;
|
||||
using static Wabbajack.NexusAPI;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -49,6 +50,8 @@ namespace Wabbajack
|
||||
|
||||
public Action<string> Log_Fn { get; }
|
||||
public List<Directive> InstallDirectives { get; private set; }
|
||||
public string NexusKey { get; private set; }
|
||||
internal UserStatus User { get; private set; }
|
||||
public List<Archive> SelectedArchives { get; private set; }
|
||||
public List<RawSourceFile> AllFiles { get; private set; }
|
||||
public ModList ModList { get; private set; }
|
||||
@ -187,6 +190,15 @@ namespace Wabbajack
|
||||
|
||||
InstallDirectives = results.Where(i => !(i is IgnoredDirectly)).ToList();
|
||||
|
||||
NexusKey = NexusAPI.GetNexusAPIKey();
|
||||
User = NexusAPI.GetUserStatus(NexusKey);
|
||||
|
||||
if (!User.is_premium)
|
||||
{
|
||||
Info($"User {User.name} is not a premium Nexus user, cannot continue");
|
||||
}
|
||||
|
||||
|
||||
GatherArchives();
|
||||
BuildPatches();
|
||||
|
||||
@ -319,7 +331,7 @@ namespace Wabbajack
|
||||
.Select(a => a.ArchiveHash)
|
||||
.Distinct();
|
||||
|
||||
SelectedArchives = shas.Select(sha => ResolveArchive(sha, archives)).ToList();
|
||||
SelectedArchives = shas.PMap(sha => ResolveArchive(sha, archives));
|
||||
|
||||
}
|
||||
|
||||
@ -343,6 +355,16 @@ namespace Wabbajack
|
||||
FileID = general.fileID,
|
||||
ModID = general.modID
|
||||
};
|
||||
Status($"Getting Nexus info for {found.Name}");
|
||||
try
|
||||
{
|
||||
var info = NexusAPI.GetFileInfo((NexusMod)result, NexusKey);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Error($"Unable to resolve {found.Name} on the Nexus was the file removed?");
|
||||
}
|
||||
|
||||
}
|
||||
else if (general.directURL != null && general.directURL.StartsWith("https://drive.google.com"))
|
||||
{
|
||||
|
@ -1,3 +1,10 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<Costura />
|
||||
<Costura>
|
||||
<Unmanaged64Assemblies>
|
||||
7z
|
||||
</Unmanaged64Assemblies>
|
||||
<PreloadOrder>
|
||||
7z
|
||||
</PreloadOrder>
|
||||
</Costura>
|
||||
</Weavers>
|
@ -108,5 +108,36 @@ namespace Wabbajack
|
||||
}
|
||||
}
|
||||
|
||||
public class NexusFileInfo
|
||||
{
|
||||
public ulong file_id;
|
||||
public string name;
|
||||
public string version;
|
||||
public ulong category_id;
|
||||
public string category_name;
|
||||
public bool is_primary;
|
||||
public ulong size;
|
||||
public string file_name;
|
||||
public ulong uploaded_timestamp;
|
||||
public DateTime uploaded_time;
|
||||
public string mod_version;
|
||||
public string external_virus_scan_url;
|
||||
public string description;
|
||||
public ulong size_kb;
|
||||
public string changelog_html;
|
||||
}
|
||||
|
||||
|
||||
public static NexusFileInfo GetFileInfo(NexusMod mod, string apikey)
|
||||
{
|
||||
var url = $"https://api.nexusmods.com/v1/games/{ConvertGameName(mod.GameName)}/mods/{mod.ModID}/files/{mod.FileID}.json";
|
||||
var client = BaseNexusClient(apikey);
|
||||
|
||||
using (var s = client.GetStreamSync(url))
|
||||
{
|
||||
return s.FromJSON<NexusFileInfo>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user