mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
47 lines
1.9 KiB
C#
47 lines
1.9 KiB
C#
using System.Threading.Tasks;
|
|
using CommandLine;
|
|
using Wabbajack.Common;
|
|
using Wabbajack.Lib;
|
|
using Wabbajack.Lib.Downloaders;
|
|
|
|
namespace Wabbajack.CLI.Verbs
|
|
{
|
|
[Verb("force-healing", HelpText = "Forces a given source download to be healed by a given new-er download. The new download must be valid.")]
|
|
public class ForceHealing : AVerb
|
|
{
|
|
[Option('o', "old", Required = true, HelpText = "Old Archive (must have an attached .meta)")]
|
|
public string _old { get; set; } = "";
|
|
|
|
public AbsolutePath Old => (AbsolutePath)_old;
|
|
[Option('n', "new", Required = true, HelpText = "New Archive (must have an attached .meta)")]
|
|
public string _new { get; set; } = "";
|
|
public AbsolutePath New => (AbsolutePath)_new;
|
|
|
|
|
|
protected override async Task<ExitCode> Run()
|
|
{
|
|
Utils.Log("Loading Meta files");
|
|
var oldState = (AbstractDownloadState)await DownloadDispatcher.ResolveArchive(Old.WithExtension(Consts.MetaFileExtension).LoadIniFile());
|
|
var newState = (AbstractDownloadState)await DownloadDispatcher.ResolveArchive(New.WithExtension(Consts.MetaFileExtension).LoadIniFile());
|
|
Utils.Log("Hashing archives");
|
|
|
|
var oldHash = await Old.FileHashCachedAsync();
|
|
var newHash = await New.FileHashCachedAsync();
|
|
|
|
if (oldHash == null)
|
|
return ExitCode.Error;
|
|
|
|
if (newHash == null)
|
|
return ExitCode.Error;
|
|
|
|
var oldArchive = new Archive(oldState) {Hash = oldHash!.Value, Size = Old.Size};
|
|
var newArchive = new Archive(newState) {Hash = newHash!.Value, Size = New.Size};
|
|
|
|
Utils.Log($"Contacting Server to request patch ({oldHash} -> {newHash}");
|
|
Utils.Log($"Response: {await ClientAPI.GetModUpgrade(oldArchive, newArchive, useAuthor: true)}");
|
|
|
|
return ExitCode.Ok;
|
|
}
|
|
}
|
|
}
|