From f78ce69473736a2fba8cc14ca7e61d82abc3b4cd Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 3 Jan 2022 19:45:28 +0000 Subject: [PATCH] --- .vscode/launch.json | 1 + .../AyaNova/Controllers/LogFilesController.cs | 22 +++++++++---------- server/AyaNova/Startup.cs | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index cddfae1f..c0f0d08d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -47,6 +47,7 @@ "AYANOVA_DB_CONNECTION": "Server=localhost;Username=postgres;Password=raven;Database=AyaNova;CommandTimeout=120;", "AYANOVA_DATA_PATH": "c:\\temp\\ravendata", "AYANOVA_USE_URLS": "http://*:7575;", + //"AYANOVA_PERMANENTLY_ERASE_DATABASE":"true", "AYANOVA_SERVER_TEST_MODE": "false", //"AYANOVA_REPORT_RENDERING_TIMEOUT":"60", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", diff --git a/server/AyaNova/Controllers/LogFilesController.cs b/server/AyaNova/Controllers/LogFilesController.cs index b624b510..42519def 100644 --- a/server/AyaNova/Controllers/LogFilesController.cs +++ b/server/AyaNova/Controllers/LogFilesController.cs @@ -53,8 +53,8 @@ namespace AyaNova.Api.Controllers [HttpGet("{logname}")] public ActionResult GetLog([FromRoute] string logname) { - if (serverState.IsClosed) - return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + // if (serverState.IsClosed) + // return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.LogFile)) { @@ -93,8 +93,8 @@ namespace AyaNova.Api.Controllers [HttpGet()] public ActionResult ListLogs() { - if (serverState.IsClosed) - return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + // if (serverState.IsClosed) + // return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.LogFile)) { @@ -126,8 +126,8 @@ namespace AyaNova.Api.Controllers [HttpGet("download/{logname}")] public async Task DownloadLog([FromRoute] string logname, [FromQuery] string t) { - if (serverState.IsClosed) - return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + // if (serverState.IsClosed) + // return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); if (!ModelState.IsValid) return BadRequest(new ApiErrorResponse(ModelState)); @@ -139,13 +139,13 @@ namespace AyaNova.Api.Controllers return StatusCode(401, new ApiErrorResponse(ApiErrorCode.AUTHENTICATION_FAILED)); } - if (!Authorized.HasReadFullRole(user.Roles, AyaType.LogFile)) - return StatusCode(403, new ApiNotAuthorizedResponse()); + if (!Authorized.HasReadFullRole(user.Roles, AyaType.LogFile)) + return StatusCode(403, new ApiNotAuthorizedResponse()); - var logFilePath = System.IO.Path.Combine(ServerBootConfig.AYANOVA_LOG_PATH, logname); - if (!System.IO.File.Exists(logFilePath)) + var logFilePath = System.IO.Path.Combine(ServerBootConfig.AYANOVA_LOG_PATH, logname); + if (!System.IO.File.Exists(logFilePath)) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND)); - + return PhysicalFile(logFilePath, "text/plain", $"{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}-{logname}"); } diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index ec07dd3a..6c84eaac 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -542,7 +542,7 @@ namespace AyaNova } else { - _newLog.LogWarning("AYANOVA_PERMANENTLY_ERASE_DATABASE, dropping and recreating database"); + _newLog.LogWarning("AYANOVA_PERMANENTLY_ERASE_DATABASE has been set - deleting and recreating database"); } Util.DbUtil.DropAndRecreateDbAsync(_newLog).Wait(); AySchema.CheckAndUpdateAsync(dbContext, _newLog).Wait();