将 config 写入改为原子写入,防止潜在的异常中断导致配置文件失效问题
This commit is contained in:
3 files changed
+41
-1
No files matched your search
@@ -112,7 +112,7 @@ public class JsonConfigProvider : IConfigProvider {
|
||||
public void Save() {
|
||||
if (!isDirty) return;
|
||||
isDirty = false;
|
||||
lock (this) FileUtils.Write(filePath, json.Value.ToString(Formatting.Indented));
|
||||
lock (this) FileUtils.WriteAtomic(filePath, json.Value.ToString(Formatting.Indented));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user