diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Db.cs (renamed from src/Eva.cs) | 4 | ||||
| -rw-r--r-- | src/Migrations/20230112230354_InitialCreate.Designer.cs | 2 | ||||
| -rw-r--r-- | src/Migrations/20230115182252_DeletionKey.Designer.cs | 2 | ||||
| -rw-r--r-- | src/Migrations/DBModelSnapshot.cs | 2 | ||||
| -rw-r--r-- | src/Program.cs | 20 | ||||
| -rw-r--r-- | src/WallE.cs | 2 |
6 files changed, 16 insertions, 16 deletions
@@ -2,11 +2,11 @@ using Microsoft.EntityFrameworkCore; namespace BlobBin; -public sealed class Eva : DbContext +public sealed class Db : DbContext { private readonly bool migrated; - public Eva(DbContextOptions<Eva> options) : base(options) { + public Db(DbContextOptions<Db> options) : base(options) { if (!migrated) { Database.Migrate(); migrated = true; diff --git a/src/Migrations/20230112230354_InitialCreate.Designer.cs b/src/Migrations/20230112230354_InitialCreate.Designer.cs index 1928f19..8235c56 100644 --- a/src/Migrations/20230112230354_InitialCreate.Designer.cs +++ b/src/Migrations/20230112230354_InitialCreate.Designer.cs @@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace BlobBin.Migrations { - [DbContext(typeof(Eva))] + [DbContext(typeof(Db))] [Migration("20230112230354_InitialCreate")] partial class InitialCreate { diff --git a/src/Migrations/20230115182252_DeletionKey.Designer.cs b/src/Migrations/20230115182252_DeletionKey.Designer.cs index baf9730..6204d1f 100644 --- a/src/Migrations/20230115182252_DeletionKey.Designer.cs +++ b/src/Migrations/20230115182252_DeletionKey.Designer.cs @@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace BlobBin.Migrations { - [DbContext(typeof(Eva))] + [DbContext(typeof(Db))] [Migration("20230115182252_DeletionKey")] partial class DeletionKey { diff --git a/src/Migrations/DBModelSnapshot.cs b/src/Migrations/DBModelSnapshot.cs index e63af59..5a68283 100644 --- a/src/Migrations/DBModelSnapshot.cs +++ b/src/Migrations/DBModelSnapshot.cs @@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace BlobBin.Migrations { - [DbContext(typeof(Eva))] + [DbContext(typeof(Db))] partial class DBModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) diff --git a/src/Program.cs b/src/Program.cs index 9d5cfdd..07b04cd 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -6,7 +6,7 @@ using File = BlobBin.File; const long MAX_REQUEST_BODY_SIZE = 104_857_600; var builder = WebApplication.CreateBuilder(args); -builder.Services.AddDbContext<Eva>(); +builder.Services.AddDbContext<Db>(); builder.Services.AddHostedService<WallE>(); builder.WebHost.UseKestrel(o => { o.Limits.MaxRequestBodySize = MAX_REQUEST_BODY_SIZE; }); var app = builder.Build(); @@ -25,7 +25,7 @@ app.MapPost("/p/{id}", GetPaste); Tools.GetFilesDirectoryPath(true); app.Run(); -IResult DeleteUpload(HttpContext context, Eva db, string id, string key = default, bool confirmed = false) { +IResult DeleteUpload(HttpContext context, Db db, string id, string key = default, bool confirmed = false) { if (key.IsNullOrWhiteSpace()) { return Results.BadRequest("No key was found"); } @@ -70,7 +70,7 @@ The file is marked for deletion and cannot be accessed any more, all traces off """); } -IResult GetFileUploadLink(HttpContext context, Eva db) { +IResult GetFileUploadLink(HttpContext context, Db db) { var file = new File { CreatedBy = context.Request.Headers["X-Forwarded-For"].ToString() }; @@ -83,7 +83,7 @@ IResult GetFileUploadLink(HttpContext context, Eva db) { ); } -async Task<IResult> UploadFile(HttpContext context, Eva db) { +async Task<IResult> UploadFile(HttpContext context, Db db) { if (!context.Request.Form.Files.Any()) { return Results.BadRequest("No files was found in request"); } @@ -123,11 +123,11 @@ To delete the file, open this url in a browser {context.Request.GetRequestHost() """); } -IResult UploadFilePart(HttpContext context, Eva db) { +IResult UploadFilePart(HttpContext context, Db db) { return Results.Ok(); } -async Task<IResult> UploadText(HttpContext context, Eva db) { +async Task<IResult> UploadText(HttpContext context, Db db) { if (context.Request.Form["content"].ToString().IsNullOrWhiteSpace()) { return Results.Text("No content was found in request", default, default, 400); } @@ -168,7 +168,7 @@ To delete the paste, open this url in a browser {context.Request.GetRequestHost( """); } -async Task<IResult> GetPaste(HttpContext context, string id, Eva db) { +async Task<IResult> GetPaste(HttpContext context, string id, Db db) { var paste = db.Pastes.FirstOrDefault(c => c.PublicId == id.Trim()); if (paste is not {DeletedAt: null}) return Results.NotFound(); if (paste.PasswordHash.HasValue()) { @@ -208,7 +208,7 @@ async Task<IResult> GetPaste(HttpContext context, string id, Eva db) { return Results.Content(paste.Content, paste.MimeType, Encoding.UTF8); } -async Task<IResult> GetFile(HttpContext context, Eva db, string id, bool download = false) { +async Task<IResult> GetFile(HttpContext context, Db db, string id, bool download = false) { var file = db.Files.FirstOrDefault(c => c.PublicId == id.Trim()); if (file is not {DeletedAt: null}) return Results.NotFound(); if (file.PasswordHash.HasValue()) { @@ -261,7 +261,7 @@ bool ShouldDeleteUpload(UploadEntityBase entity) { return DateTime.Compare(DateTime.UtcNow, deletedDateTime) > 0; } -string GetUnusedPublicFileId(Eva db) { +string GetUnusedPublicFileId(Db db) { string id() => RandomString.Generate(3); var res = id(); while (db.Files.Any(c => c.PublicId == res)) { @@ -271,7 +271,7 @@ string GetUnusedPublicFileId(Eva db) { return res; } -string GetUnusedPublicPasteId(Eva db) { +string GetUnusedPublicPasteId(Db db) { string id() => RandomString.Generate(3); var res = id(); while (db.Pastes.Any(c => c.PublicId == res)) { diff --git a/src/WallE.cs b/src/WallE.cs index ae78050..b675d02 100644 --- a/src/WallE.cs +++ b/src/WallE.cs @@ -21,7 +21,7 @@ public class WallE : BackgroundService private async Task DoWork(CancellationToken stoppingToken) { _logger.LogInformation("WallE is working."); using var scope = Services.CreateScope(); - var eva = scope.ServiceProvider.GetRequiredService<Eva>(); + var eva = scope.ServiceProvider.GetRequiredService<Db>(); var pastes = eva.Pastes.Where(c => c.DeletedAt != default || c.AutoDeleteAfter != default) .Select(c => new Paste() { Id = c.Id, |
