fix(transfer): 修复部分情况下无法正确统计已完成任务总大小的问题

- get_directory_size 使用 os.scandir 递归遍历提升性能
- 当任务文件项存储类型为 local 时,若其大小为空,则通过 SystemUtils 获取目录大小以确保
完成任务的准确统计。

fix(cache): 修改 fresh 和 async_fresh 默认参数为 True

refactor(filemanager): 移除整理后总大小计算逻辑

- 删除 TransHandler 中对整理目录总大小的冗余计算,提升性能并简化流程。

perf(system): 使用 scandir 优化文件扫描性能

- 重构 SystemUtils 中的文件扫描方法(list_files、exists_file、list_sub_files),
- 采用 os.scandir 替代 glob 实现,并预编译正则表达式以提升目录遍历与文件匹配性能。
This commit is contained in:
Attente
2025-10-23 19:21:24 +08:00
parent 0c58eae5e7
commit 7421ca09cc
4 changed files with 88 additions and 49 deletions

View File

@@ -1016,7 +1016,7 @@ class AsyncFileBackend(AsyncCacheBackend):
@contextmanager
def fresh(fresh: bool = False):
def fresh(fresh: bool = True):
"""
是否获取新数据(不使用缓存的值)
@@ -1031,7 +1031,7 @@ def fresh(fresh: bool = False):
_fresh.reset(token)
@asynccontextmanager
async def async_fresh(fresh: bool = False):
async def async_fresh(fresh: bool = True):
"""
是否获取新数据(不使用缓存的值)