refactor(storage): 将文件存储读取操作改为异步模式

- 使用 await using 替代 using 确保异步资源正确释放
- 优化文件读取流程以支持异步IO操作
- 提高文件存储组件的异步处理能力
This commit is contained in:
GeWuYou 2026-01-27 22:39:26 +08:00
parent a29a484834
commit 4cfc5d3505

View File

@ -207,7 +207,7 @@ public sealed class FileStorage : IFileStorage
// 读取文件内容可以使用异步IO但要注意锁范围
string content;
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
await using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var sr = new StreamReader(fs, Encoding.UTF8))
{
content = await sr.ReadToEndAsync();