mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Can now purge the cache, and extracs BSAs from the cli
This commit is contained in:
parent
83f49bab59
commit
af0c3085e8
@ -23,7 +23,9 @@ namespace Wabbajack.CLI
|
||||
typeof(BSADump),
|
||||
typeof(MigrateGameFolderFiles),
|
||||
typeof(HashFile),
|
||||
typeof(InlinedFileReport)
|
||||
typeof(InlinedFileReport),
|
||||
typeof(ExtractBSA),
|
||||
typeof(PurgeNexusCache)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -14,22 +14,7 @@ namespace Wabbajack.CLI
|
||||
Utils.LogMessages.Subscribe(Console.WriteLine);
|
||||
return Parser.Default.ParseArguments(args, OptionsDefinition.AllOptions)
|
||||
.MapResult(
|
||||
(Encrypt opts) => opts.Execute(),
|
||||
(Decrypt opts) => opts.Execute(),
|
||||
(Validate opts) => opts.Execute(),
|
||||
(DownloadUrl opts) => opts.Execute(),
|
||||
(UpdateModlists opts) => opts.Execute(),
|
||||
(UpdateNexusCache opts) => opts.Execute(),
|
||||
(ChangeDownload opts) => opts.Execute(),
|
||||
(ServerLog opts) => opts.Execute(),
|
||||
(MyFiles opts) => opts.Execute(),
|
||||
(DeleteFile opts) => opts.Execute(),
|
||||
(Changelog opts) => opts.Execute(),
|
||||
(FindSimilar opts) => opts.Execute(),
|
||||
(BSADump opts) => opts.Execute(),
|
||||
(MigrateGameFolderFiles opts) => opts.Execute(),
|
||||
(HashFile opts) => opts.Execute(),
|
||||
(InlinedFileReport opts) => opts.Execute(),
|
||||
(AVerb opts) => opts.Execute(),
|
||||
errs => 1);
|
||||
}
|
||||
}
|
||||
|
35
Wabbajack.CLI/Verbs/ExtractBSA.cs
Normal file
35
Wabbajack.CLI/Verbs/ExtractBSA.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using CommandLine;
|
||||
using Compression.BSA;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack.CLI.Verbs
|
||||
{
|
||||
[Verb("extract-bsa", HelpText = "Extracts a BSA/BA2 into a folder")]
|
||||
public class ExtractBSA : AVerb
|
||||
{
|
||||
[Option('o', "output", Required = true, HelpText = @"Output folder to extract to")]
|
||||
public string OutputFolder { get; set; } = "";
|
||||
|
||||
[IsFile(CustomMessage = "The input file %1 does not exist!")]
|
||||
[Option('i', "input", Required = true, HelpText = @"BSA/BA2 to extract")]
|
||||
public string InputFile { get; set; } = "";
|
||||
|
||||
protected override async Task<ExitCode> Run()
|
||||
{
|
||||
Console.WriteLine($"Extracting {InputFile} to {OutputFolder}");
|
||||
var bsa = await BSADispatch.OpenRead((AbsolutePath)InputFile);
|
||||
foreach (var file in bsa.Files)
|
||||
{
|
||||
Console.WriteLine($"Extracting {file.Path}");
|
||||
var ofile = file.Path.RelativeTo((AbsolutePath)OutputFolder);
|
||||
ofile.Parent.CreateDirectory();
|
||||
await using var ostream = await ofile.Create();
|
||||
await file.CopyDataTo(ostream);
|
||||
}
|
||||
|
||||
return ExitCode.Ok;
|
||||
}
|
||||
}
|
||||
}
|
19
Wabbajack.CLI/Verbs/PurgeNexusCache.cs
Normal file
19
Wabbajack.CLI/Verbs/PurgeNexusCache.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using CommandLine;
|
||||
using Wabbajack.Lib.FileUploader;
|
||||
|
||||
namespace Wabbajack.CLI.Verbs
|
||||
{
|
||||
[Verb("purge-nexus-cache", HelpText = "Purge the Wabbajack Server's info about a given nexus Mod ID. Future requests for this mod will be grabbed from the Nexus")]
|
||||
public class PurgeNexusCache : AVerb
|
||||
{
|
||||
[Option('i', "mod-id", Required = true, HelpText = @"Mod ID to purge")]
|
||||
public long ModId { get; set; } = 0;
|
||||
protected override async Task<ExitCode> Run()
|
||||
{
|
||||
Console.WriteLine(await AuthorAPI.PurgeNexusModInfo(ModId));
|
||||
return ExitCode.Ok;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,8 +6,8 @@
|
||||
<AssemblyName>wabbajack-cli</AssemblyName>
|
||||
<Company>Wabbajack</Company>
|
||||
<Platforms>x64</Platforms>
|
||||
<AssemblyVersion>2.1.0.2</AssemblyVersion>
|
||||
<FileVersion>2.1.0.2</FileVersion>
|
||||
<AssemblyVersion>2.1.0.1</AssemblyVersion>
|
||||
<FileVersion>2.1.0.1</FileVersion>
|
||||
<Copyright>Copyright © 2019-2020</Copyright>
|
||||
<Description>An automated ModList installer</Description>
|
||||
<PublishReadyToRun>true</PublishReadyToRun>
|
||||
|
@ -69,5 +69,10 @@ namespace Wabbajack.Lib.FileUploader
|
||||
.DeleteStringAsync($"{Consts.WabbajackBuildServerUri}uploaded_files/{name}");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async Task<string> PurgeNexusModInfo(long modId)
|
||||
{
|
||||
return await (await GetAuthorizedClient()).GetStringAsync($"{Consts.WabbajackBuildServerUri}purge_nexus_cache/{modId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.FileUploader;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Server.DataLayer;
|
||||
using Wabbajack.Server.DTOs;
|
||||
@ -58,6 +59,30 @@ namespace Wabbajack.BuildServer.Test
|
||||
Assert.Single(modInfoResponse.files);
|
||||
Assert.Equal("blerg", modInfoResponse.files.First().file_name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestCanPurgeModInfo()
|
||||
{
|
||||
var sqlService = Fixture.GetService<SqlService>();
|
||||
var modId = long.MaxValue >> 3;
|
||||
await sqlService.AddNexusModFiles(Game.SkyrimSpecialEdition, modId, DateTime.Now,
|
||||
new NexusApiClient.GetModFilesResponse {files = new List<NexusFileInfo>
|
||||
{
|
||||
new NexusFileInfo
|
||||
{
|
||||
file_name = "blerg"
|
||||
}
|
||||
}});
|
||||
|
||||
var api = await NexusApiClient.Get();
|
||||
|
||||
var modInfoResponse = await api.GetModFiles(Game.SkyrimSpecialEdition, modId);
|
||||
|
||||
Assert.Single(modInfoResponse.files);
|
||||
Assert.Equal("blerg", modInfoResponse.files.First().file_name);
|
||||
|
||||
await AuthorAPI.PurgeNexusModInfo(modId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CanQueryAndFindNexusModfilesFast()
|
||||
|
@ -112,5 +112,15 @@ namespace Wabbajack.BuildServer.Controllers
|
||||
Response.Headers.Add("x-cache-result", method);
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize(Roles ="Author")]
|
||||
[Route("/purge_nexus_cache/{ModId}")]
|
||||
public async Task<IActionResult> PurgeNexusCache(long ModId)
|
||||
{
|
||||
_logger.LogInformation($"Purging nexus cache for {ModId}");
|
||||
await _sql.PurgeNexusCache(ModId);
|
||||
return Ok("Purged");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,5 +108,12 @@ namespace Wabbajack.Server.DataLayer
|
||||
new {Game = game.MetaData().NexusGameId, ModId = modId});
|
||||
return result == null ? null : JsonConvert.DeserializeObject<NexusApiClient.GetModFilesResponse>(result);
|
||||
}
|
||||
|
||||
public async Task PurgeNexusCache(long modId)
|
||||
{
|
||||
await using var conn = await Open();
|
||||
await conn.ExecuteAsync("DELETE FROM dbo.NexusModFiles WHERE ModId = @ModId", new {ModId = modId});
|
||||
await conn.ExecuteAsync("DELETE FROM dbo.NexusModInfos WHERE ModId = @ModId", new {ModId = modId});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ namespace Wabbajack.Server.Services
|
||||
new DiscordMessage
|
||||
{
|
||||
Content =
|
||||
$"Removing patch from {patch.Src.Archive.State.PrimaryKeyString} to {patch.Dest.Archive.State.PrimaryKeyString} due it no longer being required by curated lists"
|
||||
$"Removing {patch.PatchSize.FileSizeToString()} patch from {patch.Src.Archive.State.PrimaryKeyString} to {patch.Dest.Archive.State.PrimaryKeyString} due it no longer being required by curated lists"
|
||||
});
|
||||
|
||||
if (!await DeleteFromCDN(client, PatchName(patch)))
|
||||
|
@ -36,10 +36,10 @@ namespace Wabbajack.Server
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSwaggerGen(c =>
|
||||
/*services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo {Title = "Wabbajack Build API", Version = "v1"});
|
||||
});
|
||||
});*/
|
||||
|
||||
services.AddAuthentication(options =>
|
||||
{
|
||||
@ -99,12 +99,14 @@ namespace Wabbajack.Server
|
||||
provider.Mappings[".wabbajack"] = "application/zip";
|
||||
app.UseStaticFiles();
|
||||
|
||||
/*
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Wabbajack Build API");
|
||||
c.RoutePrefix = string.Empty;
|
||||
});
|
||||
}); */
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthentication();
|
||||
|
Loading…
Reference in New Issue
Block a user