mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
fix: 基建自定义配置迁移加个try
This commit is contained in:
@@ -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<CustomInfrastConfig>(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<CustomInfrastConfig>(jsonStr) is not CustomInfrastConfig root)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return root.Plans.Any(i => i.Period.Count > 0) ? -1 : i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user