mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Soe error handling
This commit is contained in:
parent
798b07c715
commit
25dd5a0474
@ -52,21 +52,8 @@ public class Proxy : ControllerBase
|
||||
public async Task<IActionResult> ProxyHead(CancellationToken token, [FromQuery] Uri uri, [FromQuery] string? name,
|
||||
[FromQuery] string? hash)
|
||||
{
|
||||
var shouldMatch = hash != null ? Hash.FromHex(hash) : default;
|
||||
_logger.LogInformation("Got proxy head request for {Uri}", uri);
|
||||
var state = _dispatcher.Parse(uri);
|
||||
var cacheName = (await Encoding.UTF8.GetBytes(uri.ToString()).Hash()).ToHex();
|
||||
var cacheFile = _appSettings.ProxyPath.Combine(cacheName);
|
||||
|
||||
if (!cacheFile.FileExists())
|
||||
return NotFound();
|
||||
|
||||
if (shouldMatch != default)
|
||||
if (await _hashCache.FileHashCachedAsync(cacheFile, token) != shouldMatch)
|
||||
return NotFound();
|
||||
|
||||
return Ok();
|
||||
|
||||
return new RedirectResult(_redirectUrl + cacheName);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -164,11 +151,20 @@ public class Proxy : ControllerBase
|
||||
|
||||
private async Task<CacheStatus?> GetCacheEntry(string name)
|
||||
{
|
||||
var info = await _s3.GetObjectMetadataAsync(new GetObjectMetadataRequest()
|
||||
GetObjectMetadataResponse info;
|
||||
try
|
||||
{
|
||||
BucketName = _bucket,
|
||||
Key = name
|
||||
});
|
||||
info = await _s3.GetObjectMetadataAsync(new GetObjectMetadataRequest()
|
||||
{
|
||||
BucketName = _bucket,
|
||||
Key = name,
|
||||
});
|
||||
}
|
||||
catch (Exception _)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (info.HttpStatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
return null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user