Skip to content

Commit

Permalink
- 将计算目录中所有文件总大小移动到 modules.filemanager 模块中。
Browse files Browse the repository at this point in the history
  • Loading branch information
wikrin committed Oct 28, 2024
1 parent 8add8ed commit 4d6ed7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 2 additions & 4 deletions app/chain/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,17 @@ def __do_transfer(self, fileitem: FileItem,
# 处理所有待整理目录或文件,默认一个整理路径或文件只有一个媒体信息
for trans_item in trans_items:
item_path = Path(trans_item.path)
# 是否是蓝光路径
# 是否蓝光路径
bluray_dir = trans_item.storage == "local" and SystemUtils.is_bluray_dir(item_path)
# 如果是目录且不是⼀蓝光原盘,获取所有文件并整理
if trans_item.type == "dir" and not bluray_dir:
# 遍历获取下载目录所有文件(递归)
if (files := self.storagechain.list_files(trans_item, recursion=True)): file_items.extend(files)
# 如果是蓝光目录,计算⼤⼩
elif bluray_dir:
# 计算目录下文件总大小
trans_item.size = sum(file.stat().st_size for file in item_path.rglob('*') if file.is_file())
bluray.append(trans_item)
# 单个文件
else:
# 文件或蓝光目录
file_items.append(trans_item)

if formaterHandler:
Expand Down
4 changes: 3 additions & 1 deletion app/modules/filemanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,12 +884,14 @@ def transfer_media(self,
need_notify=need_notify)

logger.info(f"文件夹 {fileitem.path} 整理成功")
# 计算目录下所有文件大小
total_size = sum(file.stat().st_size for file in Path(fileitem.path).rglob('*') if file.is_file())
# 返回整理后的路径
return TransferInfo(success=True,
fileitem=fileitem,
target_item=new_diritem,
target_diritem=new_diritem,
total_size=fileitem.size,
total_size=total_size,
need_scrape=need_scrape,
transfer_type=transfer_type)
else:
Expand Down

0 comments on commit 4d6ed7d

Please sign in to comment.