Compare commits

...

3 Commits

Author SHA1 Message Date
ded577f40a feat: add path depending on OS
Some checks failed
.NET Test Pipeline / build-and-test (pull_request) Failing after 1m56s
2024-06-01 07:27:18 +03:00
32621515db fix: default value is null for optional body 2024-06-01 07:26:22 +03:00
fdf0ecc9ef feat: add is default path 2024-06-01 07:25:51 +03:00
2 changed files with 7 additions and 4 deletions

View File

@ -6,6 +6,7 @@ namespace Mirea.Api.Endpoint.Common.Services;
public static class PathBuilder public static class PathBuilder
{ {
public static bool IsDefaultPath => Environment.GetEnvironmentVariable("PATH_TO_SAVE") == null;
public static string PathToSave => Environment.GetEnvironmentVariable("PATH_TO_SAVE") ?? Directory.GetCurrentDirectory(); public static string PathToSave => Environment.GetEnvironmentVariable("PATH_TO_SAVE") ?? Directory.GetCurrentDirectory();
public static string Combine(params string[] paths) => Path.Combine([.. paths.Prepend(PathToSave)]); public static string Combine(params string[] paths) => Path.Combine([.. paths.Prepend(PathToSave)]);
} }

View File

@ -206,15 +206,17 @@ public class SetupController(ISetupToken setupToken, IMaintenanceModeNotConfigur
[HttpPost("SetLogging")] [HttpPost("SetLogging")]
[TokenAuthentication] [TokenAuthentication]
[BadRequestResponse] [BadRequestResponse]
public ActionResult<bool> SetLogging([FromBody] LoggingRequest? request) public ActionResult<bool> SetLogging([FromBody] LoggingRequest? request = null)
{ {
var settings = (request == null) switch var settings = (request == null) switch
{ {
true => new LogSettings true => new LogSettings
{ {
EnableLogToFile = true, EnableLogToFile = true,
LogFileName = "logging-", LogFileName = "log-",
LogFilePath = "logs" LogFilePath = OperatingSystem.IsWindows() || PathBuilder.IsDefaultPath ?
PathBuilder.Combine("logs") :
"/var/log/mirea"
}, },
false => new LogSettings false => new LogSettings
{ {
@ -234,7 +236,7 @@ public class SetupController(ISetupToken setupToken, IMaintenanceModeNotConfigur
[HttpPost("SetEmail")] [HttpPost("SetEmail")]
[TokenAuthentication] [TokenAuthentication]
[BadRequestResponse] [BadRequestResponse]
public ActionResult<bool> SetEmail([FromBody] EmailRequest? request) public ActionResult<bool> SetEmail([FromBody] EmailRequest? request = null)
{ {
var settings = (request == null) switch var settings = (request == null) switch
{ {