From 70c85d0e185438adcbba4853d3ce3a86fe216bcf Mon Sep 17 00:00:00 2001 From: Lani Aung Date: Sat, 10 Feb 2024 23:35:35 -0700 Subject: [PATCH] Meh --- Services/DatabaseService.cs | 7 +++---- Services/FileParserService.cs | 7 ++----- Startup.cs | 3 --- fxl.codes.kisekae.csproj | 14 +++++++------- global.json | 2 +- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/Services/DatabaseService.cs b/Services/DatabaseService.cs index 7a876ed..f7978e3 100644 --- a/Services/DatabaseService.cs +++ b/Services/DatabaseService.cs @@ -59,14 +59,15 @@ namespace fxl.codes.kisekae.Services public async void StoreToDatabase(IFormFile file) { var memoryStream = await GetAsMemoryStream(file); - var checksum = Convert.ToBase64String(SHA256.Create().ComputeHash(memoryStream.GetBuffer())); + var checksum = Convert.ToBase64String(SHA256.HashData(memoryStream.GetBuffer())); memoryStream.Position = 0; // Reset for re-read await using var context = await _contextFactory.CreateDbContextAsync(); var existing = await context.KisekaeSets .FirstOrDefaultAsync(x => string.Equals(x.FileName, file.FileName) || string.Equals(x.CheckSum, checksum)); - if (existing != null) return; + if (existing != null) context.KisekaeSets.Remove(existing); + await context.SaveChangesAsync(); _fileParserService.UnzipLzh(file, memoryStream); var directory = Path.GetFileNameWithoutExtension(file.FileName); @@ -96,8 +97,6 @@ namespace fxl.codes.kisekae.Services await context.AddAsync(kisekae); await context.SaveChangesAsync(); - - //_storage.DeleteDirectory(directory); } private async Task SetInnerFiles(Kisekae kisekae, string directory, IEnumerable filenames) diff --git a/Services/FileParserService.cs b/Services/FileParserService.cs index 205e309..ca93b57 100644 --- a/Services/FileParserService.cs +++ b/Services/FileParserService.cs @@ -5,7 +5,6 @@ using System.IO; using System.IO.IsolatedStorage; using System.Linq; using System.Reflection; -using System.Text; using fxl.codes.kisekae.Entities; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; @@ -16,7 +15,7 @@ namespace fxl.codes.kisekae.Services { public class FileParserService { - private static readonly byte[] KissHeader = Encoding.ASCII.GetBytes("KiSS"); + private static readonly byte[] KissHeader = "KiSS"u8.ToArray(); private static readonly Color Transparent = Color.Black.WithAlpha(0); private readonly ILogger _logger; @@ -57,7 +56,6 @@ namespace fxl.codes.kisekae.Services } _storage.CreateDirectory(directory); - var process = new Process { StartInfo = new ProcessStartInfo @@ -167,11 +165,10 @@ namespace fxl.codes.kisekae.Services for (var row = 0; row < height; row++) { - var span = bitmap.GetPixelRowSpan(row); for (var column = 0; column < width; column++) { var value = values[index]; - span[column] = value == 0 || value >= palette.Colors.Count ? Transparent : Color.ParseHex(palette.Colors[value].Hex); + bitmap[row, column] = value == 0 || value >= palette.Colors.Count ? Transparent : Color.ParseHex(palette.Colors[value].Hex); index++; } diff --git a/Startup.cs b/Startup.cs index 81fdda4..7fa56a5 100644 --- a/Startup.cs +++ b/Startup.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Npgsql.Logging; namespace fxl.codes.kisekae { @@ -37,8 +36,6 @@ namespace fxl.codes.kisekae if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); - NpgsqlLogManager.Provider = new ConsoleLoggingProvider(); - NpgsqlLogManager.IsParameterLoggingEnabled = true; } else { diff --git a/fxl.codes.kisekae.csproj b/fxl.codes.kisekae.csproj index d2ab6fb..a624911 100644 --- a/fxl.codes.kisekae.csproj +++ b/fxl.codes.kisekae.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true latestmajor @@ -15,15 +15,15 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + diff --git a/global.json b/global.json index 87aef9f..b5b37b6 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.0", + "version": "8.0.0", "rollForward": "latestMajor", "allowPrerelease": false }