From c0e3eccdc26e05ab7a3c8f4a00efe392906e0c9e Mon Sep 17 00:00:00 2001 From: Timerix Date: Sun, 23 Mar 2025 23:38:00 +0500 Subject: [PATCH] changed CLI settings --- .../ParadoxSaveParser.WebAPI.csproj | 19 +------------------ ParadoxSaveParser.WebAPI/Program.cs | 15 +++++++++++---- TODO.txt | 3 --- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/ParadoxSaveParser.WebAPI/ParadoxSaveParser.WebAPI.csproj b/ParadoxSaveParser.WebAPI/ParadoxSaveParser.WebAPI.csproj index c12050e..a278f18 100644 --- a/ParadoxSaveParser.WebAPI/ParadoxSaveParser.WebAPI.csproj +++ b/ParadoxSaveParser.WebAPI/ParadoxSaveParser.WebAPI.csproj @@ -13,23 +13,6 @@ - - - - - - - - - - - - - - - - - - + diff --git a/ParadoxSaveParser.WebAPI/Program.cs b/ParadoxSaveParser.WebAPI/Program.cs index 4353c7c..6b70f2f 100644 --- a/ParadoxSaveParser.WebAPI/Program.cs +++ b/ParadoxSaveParser.WebAPI/Program.cs @@ -28,7 +28,11 @@ public class Program { private static readonly IOPath _configPath = "./config.dtsod"; private static Config _config = new(); - private static readonly ILogger _loggerRoot = new ConsoleLogger(); + + private static readonly ILogger _loggerRoot = new CompositeLogger( + new ConsoleLogger(), + new FileLogger("logs", "ParadoxSaveParser.WebAPI")); + private static readonly CancellationTokenSource _mainCancel = new(); private static ConcurrentDictionary _saveMetadataStorage = new(); @@ -44,9 +48,11 @@ public class Program { Console.InputEncoding = Encoding.UTF8; Console.OutputEncoding = Encoding.UTF8; + Console.CursorVisible = false; ContextLogger logger = new ContextLogger(nameof(Main), _loggerRoot); - Console.CancelKeyPress += (_, _) => + Console.CancelKeyPress += (_, e) => { + e.Cancel = true; logger.LogInfo("Ctrl+C Pressed"); _mainCancel.Cancel(); }; @@ -104,7 +110,8 @@ public class Program throw new Exception("Guid collision!"); } } - + + // ReSharper disable once NotAccessedPositionalProperty.Global public record ErrorMessage(string errorMessage); private static async TaskReturnResponse(HttpListenerContext ctx, HttpStatusCode statusCode, object response) @@ -187,7 +194,7 @@ public class Program new ErrorMessage("Invalid save format: no 'gamestate' file found")); string extractedGamestatePath = PathHelper.GetSaveFilePath(meta.id) + ".gamestate"; - zipEntry.ExtractToFile(extractedGamestatePath); + zipEntry.ExtractToFile(extractedGamestatePath, true); var gamestateStream = File.OpenRead(extractedGamestatePath); meta.status = SaveFileProcessingStatus.Parsing; diff --git a/TODO.txt b/TODO.txt index 4a8458b..8f0e74f 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,6 +1,3 @@ -DTLib.Web: - Add elapsed time to response status log message: `responded 200 (OK) in 0.03 s` - Main: Add temporary files deletion