mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix for install error with DeleteAsync
This commit is contained in:
parent
5a8f8dc7cb
commit
6d34cfc946
@ -249,6 +249,8 @@ namespace Wabbajack.Common
|
||||
}
|
||||
|
||||
public async Task DeleteAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsFile) return;
|
||||
|
||||
@ -257,6 +259,11 @@ namespace Wabbajack.Common
|
||||
var path = _path;
|
||||
await CircuitBreaker.WithAutoRetryAsync<IOException>(async () => File.Delete(path));
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
// ignore, it doesn't exist so why delete it?
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
|
@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Nettle;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Server.DataLayer;
|
||||
using Wabbajack.Server.DTOs;
|
||||
@ -49,6 +52,52 @@ namespace Wabbajack.BuildServer.Controllers
|
||||
return Ok(results.ToList());
|
||||
}
|
||||
|
||||
private static readonly Func<object, string> ReportTemplate = NettleEngine.GetCompiler().Compile(@"
|
||||
<html><body>
|
||||
<h2>Tar Report for {{$.key}}</h2>
|
||||
<h3>Ban Status: {{$.status}}</h3>
|
||||
<table>
|
||||
{{each $.log }}
|
||||
<tr>
|
||||
<td>{{$.Timestamp}}</td>
|
||||
<td>{{$.Path}}</td>
|
||||
<td>{{$.Key}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
</body></html>
|
||||
");
|
||||
|
||||
[HttpGet]
|
||||
[Route("tarlog/{key}")]
|
||||
public async Task<IActionResult> TarLog(string key)
|
||||
{
|
||||
var isTarKey = await _sql.IsTarKey(key);
|
||||
|
||||
List<(DateTime, string, string)> report = new List<(DateTime, string, string)>();
|
||||
|
||||
if (isTarKey) report = await _sql.FullTarReport(key);
|
||||
|
||||
var response = ReportTemplate(new
|
||||
{
|
||||
key = key,
|
||||
status = isTarKey ? "BANNED" : "NOT BANNED",
|
||||
log = report.Select(entry => new
|
||||
{
|
||||
Timestamp = entry.Item1,
|
||||
Path = entry.Item2,
|
||||
Key = entry.Item3
|
||||
}).ToList()
|
||||
});
|
||||
return new ContentResult
|
||||
{
|
||||
ContentType = "text/html",
|
||||
StatusCode = (int) HttpStatusCode.OK,
|
||||
Content = response
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private async Task Log(DateTime timestamp, string action, string subject, string metricsKey = null)
|
||||
{
|
||||
_logger.Log(LogLevel.Information, $"Log - {timestamp} {action} {subject} {metricsKey}");
|
||||
|
@ -49,5 +49,21 @@ namespace Wabbajack.Server.DataLayer
|
||||
ORDER BY d.Date, d.GroupingSubject, d.Action", new {Action = action}))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public async Task<List<(DateTime, string, string)>> FullTarReport(string key)
|
||||
{
|
||||
await using var conn = await Open();
|
||||
return (await conn.QueryAsync<(DateTime, string, string)>(@"
|
||||
SELECT u.Timestamp, u.Path, u.MetricsKey FROM
|
||||
(SELECT al.Timestamp, JSON_VALUE(al.Action, '$.Path') as Path, al.MetricsKey FROM dbo.AccessLog al
|
||||
WHERE al.MetricsKey in (SELECT DISTINCT MetricsKey from AccessLog al WHERE al.Ip in (SELECT DISTINCT Ip from AccessLog where MetricsKey = @MetricsKey))
|
||||
UNION ALL
|
||||
SELECT m.Timestamp, m.Action + ' ' + m.Subject as Path, m.MetricsKey FROM dbo.Metrics m
|
||||
WHERE m.MetricsKey in (SELECT DISTINCT MetricsKey from AccessLog al WHERE al.Ip in (SELECT DISTINCT Ip from AccessLog where MetricsKey = @MetricsKey)
|
||||
AND m.Action != 'TarKey')) u
|
||||
ORDER BY u.Timestamp Desc",
|
||||
new {MetricsKey = key})).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user