diff --git a/project/SPT.Launcher/ViewModels/SettingsViewModel.cs b/project/SPT.Launcher/ViewModels/SettingsViewModel.cs index 86f402a..928bb49 100644 --- a/project/SPT.Launcher/ViewModels/SettingsViewModel.cs +++ b/project/SPT.Launcher/ViewModels/SettingsViewModel.cs @@ -2,9 +2,7 @@ using SPT.Launcher.Helpers; using SPT.Launcher.Models; using SPT.Launcher.Models.Launcher; -using SPT.Launcher.ViewModels.Dialogs; using Avalonia; -using Avalonia.Controls; using ReactiveUI; using System; using System.Collections.Generic; @@ -50,19 +48,42 @@ namespace SPT.Launcher.ViewModels return; } - var traceLogs = Directory.GetFiles(Path.Join(LauncherSettingsProvider.Instance.GamePath, "Logs"), $"{DateTime.Now:yyyy.MM.dd}_* traces.log", SearchOption.AllDirectories); + var filesToCopy = new List { LogManager.Instance.LogFile }; - var traceLog = traceLogs.Length > 0 ? traceLogs[0] : ""; + var serverLog = Path.Join(LauncherSettingsProvider.Instance.GamePath, @"\user\logs", + $"server-{DateTime.Now:yyyy-MM-dd}.log"); + var bepinexLog = Path.Join(LauncherSettingsProvider.Instance.GamePath, @"BepInEx\LogOutput.log"); - var filesToCopy = new string[] + if (AccountManager.SelectedAccount?.id != null) { - Path.Join(LauncherSettingsProvider.Instance.GamePath, @"\user\logs", $"server-{DateTime.Now:yyyy-MM-dd}.log"), - traceLog, - Path.Join(LauncherSettingsProvider.Instance.GamePath, @"BepInEx\LogOutput.log"), - Path.Join(LauncherSettingsProvider.Instance.GamePath, @"\user\profiles", $"{AccountManager.SelectedAccount.id}.json"), - LogManager.Instance.LogFile, - }; + filesToCopy.Add(Path.Join(LauncherSettingsProvider.Instance.GamePath, @"\user\profiles", + $"{AccountManager.SelectedAccount.id}.json")); + } + if (File.Exists(serverLog)) + { + filesToCopy.Add(serverLog); + } + + if (File.Exists(bepinexLog)) + { + filesToCopy.Add(bepinexLog); + } + + var logsPath = Path.Join(LauncherSettingsProvider.Instance.GamePath, "Logs"); + if (Directory.Exists(logsPath)) + { + var traceLogs = Directory.GetFiles(logsPath, $"{DateTime.Now:yyyy.MM.dd}_* traces.log", + SearchOption.AllDirectories); + + var log = traceLogs.Length > 0 ? traceLogs[0] : ""; + + if (!string.IsNullOrWhiteSpace(log)) + { + filesToCopy.Add(log); + } + } + List files = new List(); foreach (var logPath in filesToCopy)