Formatting

This commit is contained in:
Kieran 2022-07-25 20:38:58 +01:00
parent 007e11571b
commit ad59bdd96c
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
7 changed files with 16 additions and 15 deletions

View File

@ -96,7 +96,7 @@ public class AdminController : Controller
{ {
var oldUser = await _userStore.Get(user.Id); var oldUser = await _userStore.Get(user.Id);
if (oldUser == default) return BadRequest(); if (oldUser == default) return BadRequest();
await _userStore.AdminUpdateUser(user); await _userStore.AdminUpdateUser(user);
return Ok(); return Ok();
} }

View File

@ -45,7 +45,7 @@ public class DownloadController : Controller
var voidFile = await SetupDownload(gid); var voidFile = await SetupDownload(gid);
if (voidFile == default) return; if (voidFile == default) return;
var egressReq = new EgressRequest(gid, GetRanges(Request, (long) voidFile!.Metadata!.Size)); var egressReq = new EgressRequest(gid, GetRanges(Request, (long)voidFile!.Metadata!.Size));
if (egressReq.Ranges.Count() > 1) if (egressReq.Ranges.Count() > 1)
{ {
_logger.LogWarning("Multi-range request not supported!"); _logger.LogWarning("Multi-range request not supported!");
@ -57,10 +57,10 @@ public class DownloadController : Controller
} }
else if (egressReq.Ranges.Count() == 1) else if (egressReq.Ranges.Count() == 1)
{ {
Response.StatusCode = (int) HttpStatusCode.PartialContent; Response.StatusCode = (int)HttpStatusCode.PartialContent;
if (egressReq.Ranges.Sum(a => a.Size) == 0) if (egressReq.Ranges.Sum(a => a.Size) == 0)
{ {
Response.StatusCode = (int) HttpStatusCode.RequestedRangeNotSatisfiable; Response.StatusCode = (int)HttpStatusCode.RequestedRangeNotSatisfiable;
return; return;
} }
} }
@ -83,7 +83,7 @@ public class DownloadController : Controller
Response.ContentLength = 0; Response.ContentLength = 0;
return; return;
} }
var cts = HttpContext.RequestAborted; var cts = HttpContext.RequestAborted;
await Response.StartAsync(cts); await Response.StartAsync(cts);
await _storage.Egress(egressReq, Response.Body, cts); await _storage.Egress(egressReq, Response.Body, cts);
@ -105,7 +105,7 @@ public class DownloadController : Controller
var orderId = Request.Headers.GetHeader("V-OrderId") ?? Request.Query["orderId"]; var orderId = Request.Headers.GetHeader("V-OrderId") ?? Request.Query["orderId"];
if (!await IsOrderPaid(orderId)) if (!await IsOrderPaid(orderId))
{ {
Response.StatusCode = (int) HttpStatusCode.PaymentRequired; Response.StatusCode = (int)HttpStatusCode.PaymentRequired;
return default; return default;
} }
} }
@ -146,4 +146,4 @@ public class DownloadController : Controller
} }
} }
} }
} }

View File

@ -12,4 +12,4 @@ public class NoOpVerifier : ICaptchaVerifier
{ {
return ValueTask.FromResult(true); return ValueTask.FromResult(true);
} }
} }

View File

@ -28,7 +28,7 @@ public class S3FileStore : StreamFileStore, IFileStore
public async ValueTask<PrivateVoidFile> Ingress(IngressPayload payload, CancellationToken cts) public async ValueTask<PrivateVoidFile> Ingress(IngressPayload payload, CancellationToken cts)
{ {
if (payload.IsAppend) throw new InvalidOperationException("Cannot append to S3 store"); if (payload.IsAppend) throw new InvalidOperationException("Cannot append to S3 store");
var req = new PutObjectRequest var req = new PutObjectRequest
{ {
BucketName = _config.BucketName, BucketName = _config.BucketName,
@ -41,12 +41,12 @@ public class S3FileStore : StreamFileStore, IFileStore
ChecksumSHA256 = payload.Hash != default ? Convert.ToBase64String(payload.Hash!.FromHex()) : null, ChecksumSHA256 = payload.Hash != default ? Convert.ToBase64String(payload.Hash!.FromHex()) : null,
StreamTransferProgress = (s, e) => StreamTransferProgress = (s, e) =>
{ {
_statsCollector.TrackIngress(payload.Id, (ulong) e.IncrementTransferred) _statsCollector.TrackIngress(payload.Id, (ulong)e.IncrementTransferred)
.GetAwaiter().GetResult(); .GetAwaiter().GetResult();
}, },
Headers = Headers =
{ {
ContentLength = (long) payload.Meta.Size ContentLength = (long)payload.Meta.Size
} }
}; };
@ -145,6 +145,7 @@ public class S3FileStore : StreamFileStore, IFileStore
BucketName = _config.BucketName, BucketName = _config.BucketName,
Key = request.Id.ToString() Key = request.Id.ToString()
}; };
if (request.Ranges.Any()) if (request.Ranges.Any())
{ {
var r = request.Ranges.First(); var r = request.Ranges.First();
@ -154,4 +155,4 @@ public class S3FileStore : StreamFileStore, IFileStore
var obj = await _client.GetObjectAsync(req, cts); var obj = await _client.GetObjectAsync(req, cts);
return obj.ResponseStream; return obj.ResponseStream;
} }
} }

View File

@ -49,4 +49,4 @@ public class FixSize : IMigration
return IMigration.MigrationResult.Completed; return IMigration.MigrationResult.Completed;
} }
} }

View File

@ -22,4 +22,4 @@ public static class UsersStartup
services.AddTransient<IApiKeyStore, CacheApiKeyStore>(); services.AddTransient<IApiKeyStore, CacheApiKeyStore>();
} }
} }
} }

View File

@ -22,7 +22,7 @@ export function useApi() {
body: body ? JSON.stringify(body) : undefined body: body ? JSON.stringify(body) : undefined
}); });
} }
return { return {
AdminApi: { AdminApi: {
fileList: (pageReq) => getJson("POST", "/admin/file", pageReq, auth), fileList: (pageReq) => getJson("POST", "/admin/file", pageReq, auth),