mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
add headless mode for checking archives
This commit is contained in:
parent
14eb3e697e
commit
a186411e0b
@ -3,6 +3,7 @@
|
||||
#### Version 0.9.5 - ???
|
||||
* Set Oblivion's MO2 names to `Oblivion` not `oblivion`
|
||||
* Fix validation tests to run in CI
|
||||
* Add `check for broken archives` batch functionality
|
||||
|
||||
#### Version 0.9.4 - 10/2/2019
|
||||
* Point github icon to https://github.com/wabbajack-tools/wabbajack
|
||||
|
@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Configuration;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@ -21,6 +22,17 @@ namespace Wabbajack.Common
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
public static string LogFile { get; private set; }
|
||||
static Utils()
|
||||
{
|
||||
var program_name = Assembly.GetEntryAssembly()?.Location ?? "Wabbajack";
|
||||
LogFile = program_name + ".log";
|
||||
_startTime = DateTime.Now;
|
||||
|
||||
if (LogFile.FileExists())
|
||||
File.Delete(LogFile);
|
||||
}
|
||||
|
||||
private static Action<string> _loggerFn;
|
||||
private static Action<string, int> _statusFn;
|
||||
|
||||
@ -36,8 +48,17 @@ namespace Wabbajack.Common
|
||||
_statusFn = f;
|
||||
}
|
||||
|
||||
private static object _lock = new object();
|
||||
private static DateTime _startTime;
|
||||
|
||||
public static void Log(string msg)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
msg = $"{(DateTime.Now - _startTime).TotalSeconds:0.##} - {msg}";
|
||||
|
||||
File.AppendAllText(LogFile, msg + "\r\n");
|
||||
}
|
||||
_loggerFn?.Invoke(msg);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,8 @@
|
||||
using System.Windows;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Updater;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -7,5 +11,21 @@ namespace Wabbajack
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
public App()
|
||||
{
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
if (args.Length > 1)
|
||||
{
|
||||
Utils.SetLoggerFn(f => {});
|
||||
WorkQueue.Init((a, b, c) => {}, (a, b) => {});
|
||||
var updater = new CheckForUpdates(args[1]);
|
||||
if (updater.FindOutdatedMods())
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -72,10 +72,6 @@ namespace Wabbajack
|
||||
}
|
||||
|
||||
_startTime = DateTime.Now;
|
||||
LogFile = Assembly.GetExecutingAssembly().Location + ".log";
|
||||
|
||||
if (LogFile.FileExists())
|
||||
File.Delete(LogFile);
|
||||
|
||||
Mode = mode;
|
||||
Dirty = false;
|
||||
@ -405,12 +401,7 @@ namespace Wabbajack
|
||||
|
||||
public void LogMsg(string msg)
|
||||
{
|
||||
msg = $"{(DateTime.Now - _startTime).TotalSeconds:0.##} - {msg}";
|
||||
dispatcher.Invoke(() => Log.Add(msg));
|
||||
lock (dispatcher)
|
||||
{
|
||||
File.AppendAllText(LogFile, msg + "\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
public void SetProgress(int id, string msg, int progress)
|
||||
|
39
Wabbajack/Updater/CheckForUpdates.cs
Normal file
39
Wabbajack/Updater/CheckForUpdates.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack.Updater
|
||||
{
|
||||
public class CheckForUpdates
|
||||
{
|
||||
private ModList _modlist;
|
||||
private string _modlistPath;
|
||||
|
||||
public CheckForUpdates(string path)
|
||||
{
|
||||
_modlistPath = path;
|
||||
_modlist = Installer.LoadFromFile(path);
|
||||
}
|
||||
|
||||
public bool FindOutdatedMods()
|
||||
{
|
||||
var installer = new Installer(_modlistPath, _modlist, "");
|
||||
Utils.Log($"Checking links for {_modlist.Archives.Count} archives");
|
||||
|
||||
var results = _modlist.Archives.PMap(f =>
|
||||
{
|
||||
var result = installer.DownloadArchive(f, false);
|
||||
if (result) return false;
|
||||
Utils.Log($"Unable to resolve link for {f.Name}. If this is hosted on the Nexus the file may have been removed.");
|
||||
return true;
|
||||
|
||||
}).ToList();
|
||||
|
||||
return results.Any();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -195,6 +195,7 @@
|
||||
<Compile Include="Themes\LeftMarginMultiplierConverter.cs" />
|
||||
<Compile Include="Themes\TreeViewItemExtensions.cs" />
|
||||
<Compile Include="UIUtils.cs" />
|
||||
<Compile Include="Updater\CheckForUpdates.cs" />
|
||||
<Compile Include="Validation\DTOs.cs" />
|
||||
<Compile Include="Validation\ValidateModlist.cs" />
|
||||
<Compile Include="zEditIntegration.cs" />
|
||||
|
@ -18,7 +18,7 @@
|
||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<StartArguments>"c:\Mod Organizer 2" "Nexus SSO Test" "c:\tmp\validate"</StartArguments>
|
||||
<StartArguments>"c:\tmp\Lexys LOTD SE Unofficial Autoinstaller - 0.4.5.modlist_v1"</StartArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug %28no commandargs%29|x64'">
|
||||
<StartWorkingDirectory>c:\tmp\vstmp</StartWorkingDirectory>
|
||||
|
Loading…
Reference in New Issue
Block a user