Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion PCL.Core/App/Configuration/Storage/FileConfigStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ protected override bool OnAccess<TKey, TValue>(
{
case StorageAction.Get:
if (!File.Exists(strKey)) return false;
value = File.Get<TValue>(strKey);
try
{
value = File.Get<TValue>(strKey);
}
catch (Exception ex)

@RyogiMutsuki RyogiMutsuki Jul 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应当只捕获相关错误,而不是 catch Exception

与配置系统不相关的错误不应当导致设置项被重置

{
LogWrapper.Warn(ex, "Config", $"配置项 {strKey} 读取失败(可能已损坏),重置为默认值");
_writeActionChannel.Writer.TryWrite((strKey, () => File.Remove(strKey)));
return false;
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
}
return true;
case StorageAction.Exists:
// 由于 Exists 的 value 类型一定是 bool,此处可 unsafe 直接赋值
Expand Down
Loading