From 9357bb15241a325f1d9b3c9bb30a2ad7a8f9a028 Mon Sep 17 00:00:00 2001 From: GreemDev Date: Mon, 10 Nov 2025 19:14:19 -0600 Subject: [PATCH] UI: App Library: automatically remove nonexistent autoload/game dirs from the configuration upon load. --- .../Configuration/ConfigurationState.cs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs index 5d709d817..81b0bb232 100644 --- a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs +++ b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs @@ -13,6 +13,8 @@ using Ryujinx.UI.Common.Helper; using System; using System.Collections.Generic; using System.Globalization; +using System.IO; +using System.Linq; namespace Ryujinx.UI.Common.Configuration { @@ -1032,6 +1034,7 @@ namespace Ryujinx.UI.Common.Configuration Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Unsupported configuration version {configurationFileFormat.Version}, loading default."); LoadDefault(); + return; } if (configurationFileFormat.Version < 2) @@ -1779,6 +1782,55 @@ namespace Ryujinx.UI.Common.Configuration Ryujinx.Common.Logging.Logger.Notice.Print(LogClass.Application, $"Configuration file updated to version {ConfigurationFileFormat.CurrentVersion}"); } + + List existingDirs = []; + bool didPathUpdate = false; + + { // Game dirs + foreach (var gameDir in UI.GameDirs.Value) + { + if (Directory.Exists(gameDir)) + { + existingDirs.Add(gameDir); + } + else + { + Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Configuration, $"Path '{gameDir}' seems to no longer exist. Removing it from game directory configuration."); + didPathUpdate = true; + } + } + + UI.GameDirs.Value = existingDirs.ToList(); + } + + existingDirs.Clear(); + + { // Autoload dirs + foreach (var autoloadDir in UI.AutoloadDirs.Value) + { + if (Directory.Exists(autoloadDir)) + { + existingDirs.Add(autoloadDir); + } + else + { + Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Configuration, $"Path '{autoloadDir}' seems to no longer exist. Removing it from auto load directory configuration."); + didPathUpdate = true; + } + } + + UI.AutoloadDirs.Value = existingDirs.ToList(); + } + + if (configurationFileUpdated || didPathUpdate) + { + ToFileFormat().SaveConfig(configurationFilePath); + + if (configurationFileUpdated) + { + Ryujinx.Common.Logging.Logger.Notice.Print(LogClass.Application, $"Configuration file updated to version {ConfigurationFileFormat.CurrentVersion}"); + } + } } private static GraphicsBackend DefaultGraphicsBackend()