From 017c6bdce5c8f3183cfab4c7b4f849e8cb4b9e5e Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Fri, 26 Dec 2025 02:25:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9F=BA=E5=BB=BA=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E9=85=8D=E7=BD=AE=E8=BF=81=E7=A7=BB=E5=8A=A0=E4=B8=AA?= =?UTF-8?q?try?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InfrastSettingsUserControlModel.cs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs index 2078ad5a06..8668964680 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs @@ -374,19 +374,27 @@ public class InfrastSettingsUserControlModel : TaskViewModel return -1; } - var path = ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastFile, string.Empty); - if (!Path.Exists(path)) + try { + var path = ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastFile, string.Empty); + if (!Path.Exists(path)) + { + return -1; + } + + string jsonStr = File.ReadAllText(path); + if (JsonConvert.DeserializeObject(jsonStr) is not CustomInfrastConfig root) + { + return -1; + } + + return root.Plans.Any(i => i.Period.Count > 0) ? -1 : i; + } + catch (Exception ex) + { + _logger.Error(ex, "Failed to transform CustomInfrastPlanIndex to CustomInfrastPlanSelect"); return -1; } - - string jsonStr = File.ReadAllText(path); - if (JsonConvert.DeserializeObject(jsonStr) is not CustomInfrastConfig root) - { - return -1; - } - - return root.Plans.Any(i => i.Period.Count > 0) ? -1 : i; } return -1;