mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
crash log fixes, bug fixes, and more info during failures
This commit is contained in:
parent
197873ec1d
commit
e8f2ad2f16
@ -13,6 +13,7 @@ namespace Wabbajack.Common
|
||||
public static string GameFolderFilesDir = "Game Folder Files";
|
||||
public static string ModPackMagic = "Celebration!, Cheese for Everyone!";
|
||||
public static string BSACreationDir = "TEMP_BSA_FILES";
|
||||
public static string MegaPrefix = "https://mega.nz/#!";
|
||||
|
||||
public static HashSet<string> SupportedArchives = new HashSet<string>() { ".zip", ".rar", ".7z", ".7zip" };
|
||||
public static HashSet<string> SupportedBSAs = new HashSet<string>() { ".bsa", ".ba2" };
|
||||
|
@ -3,6 +3,7 @@ using IniParser;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
@ -244,5 +245,28 @@ namespace Wabbajack.Common
|
||||
return result.Result;
|
||||
}
|
||||
|
||||
public static string ExceptionToString(this Exception ex)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (ex != null)
|
||||
{
|
||||
sb.AppendLine(ex.Message);
|
||||
var st = new StackTrace(ex, true);
|
||||
foreach (var frame in st.GetFrames())
|
||||
{
|
||||
sb.AppendLine($"{frame.GetFileName()}:{frame.GetMethod().Name}:{frame.GetFileLineNumber()}:{frame.GetFileColumnNumber()}");
|
||||
}
|
||||
ex = ex.InnerException;
|
||||
}
|
||||
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static void CrashDump(Exception e)
|
||||
{
|
||||
File.WriteAllText($"{DateTime.Now.ToString("yyyyMMddTHHmmss_crash_log.txt")}", ExceptionToString(e));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -353,6 +353,13 @@ namespace Wabbajack
|
||||
Id = match.ToString()
|
||||
};
|
||||
}
|
||||
else if (general.directURL != null && general.directURL.StartsWith(Consts.MegaPrefix))
|
||||
{
|
||||
result = new MEGAArchive()
|
||||
{
|
||||
URL = general.directURL
|
||||
};
|
||||
}
|
||||
else if (general.directURL != null && general.directURL.StartsWith("https://www.dropbox.com/"))
|
||||
{
|
||||
var uri = new UriBuilder((string)general.directURL);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Compression.BSA;
|
||||
using CG.Web.MegaApiClient;
|
||||
using Compression.BSA;
|
||||
using SevenZipExtractor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -235,13 +236,27 @@ namespace Wabbajack
|
||||
Info("Getting Nexus API Key, if a browser appears, please accept");
|
||||
NexusAPIKey = NexusAPI.GetNexusAPIKey();
|
||||
|
||||
var user_status = NexusAPI.GetUserStatus(NexusAPIKey);
|
||||
|
||||
if (!user_status.is_premium) {
|
||||
Info($"Automated installs with Wabbajack requires a premium nexus account. {user_status.name} is not a premium account");
|
||||
return;
|
||||
}
|
||||
|
||||
DownloadMissingArchives(missing);
|
||||
return;
|
||||
}
|
||||
|
||||
private void DownloadMissingArchives(List<Archive> missing)
|
||||
{
|
||||
missing.PMap(archive =>
|
||||
{
|
||||
Info($"Downloading {archive.Name}");
|
||||
var output_path = Path.Combine(DownloadFolder, archive.Name);
|
||||
|
||||
if (output_path.FileExists())
|
||||
File.Delete(output_path);
|
||||
|
||||
switch (archive) {
|
||||
case NexusMod a:
|
||||
Info($"Downloading Nexus Archive - {archive.Name} - {a.GameName} - {a.ModID} - {a.FileID}");
|
||||
@ -257,6 +272,9 @@ namespace Wabbajack
|
||||
}
|
||||
DownloadURLDirect(archive, url);
|
||||
break;
|
||||
case MEGAArchive a:
|
||||
DownloadMegaArchive(a);
|
||||
break;
|
||||
case GoogleDriveMod a:
|
||||
DownloadGoogleDriveArchive(a);
|
||||
break;
|
||||
@ -285,6 +303,19 @@ namespace Wabbajack
|
||||
DownloadURLDirect(a, confirm.ToString(), client);
|
||||
}
|
||||
|
||||
private void DownloadMegaArchive(MEGAArchive m)
|
||||
{
|
||||
var client = new MegaApiClient();
|
||||
Status("Logging into MEGA (as anonymous)");
|
||||
client.LoginAnonymous();
|
||||
var file_link = new Uri(m.URL);
|
||||
var node = client.GetNodeFromLink(file_link);
|
||||
Status("Downloading MEGA file: {0}", m.Name);
|
||||
|
||||
var output_path = Path.Combine(DownloadFolder, m.Name);
|
||||
client.DownloadFile(file_link, output_path);
|
||||
}
|
||||
|
||||
private void DownloadGoogleDriveArchive(GoogleDriveMod a)
|
||||
{
|
||||
var initial_url = $"https://drive.google.com/uc?id={a.Id}&export=download";
|
||||
@ -329,7 +360,19 @@ namespace Wabbajack
|
||||
|
||||
var response = client.GetSync(url);
|
||||
var stream = response.Content.ReadAsStreamAsync();
|
||||
try
|
||||
{
|
||||
stream.Wait();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
};
|
||||
if (stream.IsFaulted)
|
||||
{
|
||||
Info($"While downloading {url} - {Utils.ExceptionToString(stream.Exception)}");
|
||||
return;
|
||||
}
|
||||
|
||||
string header_var = "1";
|
||||
if (response.Content.Headers.Contains("Content-Length"))
|
||||
@ -338,9 +381,7 @@ namespace Wabbajack
|
||||
long content_size = header_var != null ? long.Parse(header_var) : 1;
|
||||
|
||||
var output_path = Path.Combine(DownloadFolder, archive.Name);
|
||||
|
||||
if (output_path.FileExists())
|
||||
File.Delete(output_path);
|
||||
;
|
||||
|
||||
using (var webs = stream.Result)
|
||||
using (var fs = File.OpenWrite(output_path))
|
||||
|
@ -6,7 +6,7 @@
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
mc:Ignorable="d"
|
||||
Title="Wabbajack" Height="700" Width="800"
|
||||
Style="{StaticResource {x:Type Window}}" Icon="square_transparent_icon.ico" WindowStyle="ToolWindow">
|
||||
Style="{StaticResource {x:Type Window}}" Icon="square_transparent_icon.ico" WindowStyle="ToolWindow" Closing="Window_Closing">
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -25,6 +26,7 @@ namespace Wabbajack
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
bool DebugMode = false;
|
||||
string MO2Folder = null, InstallFolder = null, MO2Profile = null;
|
||||
@ -40,11 +42,13 @@ namespace Wabbajack
|
||||
InitializeComponent();
|
||||
|
||||
var context = new AppState(Dispatcher, "Building");
|
||||
SetupHandlers(context);
|
||||
this.DataContext = context;
|
||||
WorkQueue.Init((id, msg, progress) => context.SetProgress(id, msg, progress),
|
||||
(max, current) => context.SetQueueSize(max, current));
|
||||
|
||||
|
||||
|
||||
if (DebugMode)
|
||||
{
|
||||
new Thread(() =>
|
||||
@ -81,5 +85,23 @@ namespace Wabbajack
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private AppState _state;
|
||||
private void SetupHandlers(AppState state)
|
||||
{
|
||||
_state = state;
|
||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppHandler);
|
||||
}
|
||||
|
||||
private void AppHandler(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
_state.LogMsg("Uncaught error:");
|
||||
_state.LogMsg(Utils.ExceptionToString((Exception)e.ExceptionObject));
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,5 +84,29 @@ namespace Wabbajack
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class UserStatus
|
||||
{
|
||||
public string user_id;
|
||||
public string key;
|
||||
public string name;
|
||||
public bool is_premium;
|
||||
public bool is_supporter;
|
||||
public string email;
|
||||
public string profile_url;
|
||||
}
|
||||
|
||||
|
||||
public static UserStatus GetUserStatus(string apikey)
|
||||
{
|
||||
var url = "https://api.nexusmods.com/v1/users/validate.json";
|
||||
var client = BaseNexusClient(apikey);
|
||||
|
||||
using (var s = client.GetStreamSync(url))
|
||||
{
|
||||
return s.FromJSON<UserStatus>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,9 @@
|
||||
<Reference Include="Costura, Version=4.0.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Costura.Fody.4.0.0\lib\net40\Costura.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MegaApiClient, Version=1.7.1.495, Culture=neutral, PublicKeyToken=0480d311efbeb4e2, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MegaApiClient.1.7.1\lib\net46\MegaApiClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -2,6 +2,7 @@
|
||||
<packages>
|
||||
<package id="Costura.Fody" version="4.0.0" targetFramework="net472" />
|
||||
<package id="Fody" version="5.1.1" targetFramework="net472" developmentDependency="true" />
|
||||
<package id="MegaApiClient" version="1.7.1" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
|
||||
<package id="Ookii.Dialogs.Wpf" version="1.1.0" targetFramework="net472" />
|
||||
<package id="SharpCompress" version="0.23.0" targetFramework="net472" />
|
||||
|
Loading…
Reference in New Issue
Block a user