Cleaned up diagnose system. Fixed smaller inconsistencies

This commit is contained in:
2025-05-17 19:38:36 +02:00
parent f87e4a0800
commit 255bfba9e3
7 changed files with 153 additions and 114 deletions

View File

@@ -24,28 +24,34 @@ public class CoreConfigDiagnoseProvider : IDiagnoseProvider
public async Task ModifyZipArchive(ZipArchive archive)
{
var json = JsonSerializer.Serialize(Config);
var config = JsonSerializer.Deserialize<AppConfiguration>(json);
var config = JsonSerializer.Deserialize<AppConfiguration>(json);
if (config == null)
{
await archive.AddText("core/config.txt","Could not fetch config.");
await archive.AddText("core/config.txt", "Could not fetch config.");
return;
}
config.Database.Password = CheckForNullOrEmpty(config.Database.Password);
config.Authentication.OAuth2.ClientSecret = CheckForNullOrEmpty(config.Authentication.OAuth2.ClientSecret);
config.Authentication.OAuth2.Secret = CheckForNullOrEmpty(config.Authentication.OAuth2.Secret);
config.Authentication.Secret = CheckForNullOrEmpty(config.Authentication.Secret);
config.Authentication.OAuth2.ClientId = CheckForNullOrEmpty(config.Authentication.OAuth2.ClientId);
await archive.AddText("core/config.txt",
JsonSerializer.Serialize(config, new JsonSerializerOptions() { WriteIndented = true }));
await archive.AddText(
"core/config.txt",
JsonSerializer.Serialize(
config,
new JsonSerializerOptions()
{
WriteIndented = true
}
)
);
}
}

View File

@@ -1,6 +1,4 @@
using System.IO.Compression;
using System.Text;
using MoonCore.Helpers;
using Moonlight.ApiServer.Extensions;
using Moonlight.ApiServer.Interfaces;
@@ -10,15 +8,15 @@ public class LogsDiagnoseProvider : IDiagnoseProvider
{
public async Task ModifyZipArchive(ZipArchive archive)
{
var path = Path.Combine("storage", "logs", "latest.log");
var logs = await File.ReadAllTextAsync(PathBuilder.File("storage", "logs", "latest.log"));
if (string.IsNullOrEmpty(logs))
{
await archive.AddText("logs.txt", "Could not read the logs");
return;
}
await archive.AddText("logs.txt", logs);
if (!File.Exists(path))
{
await archive.AddText("logs.txt", "Logs file latest.log has not been found");
return;
}
var logsContent = await File.ReadAllTextAsync(path);
await archive.AddText("logs.txt", logsContent);
}
}