diff --git a/app/chain/transfer.py b/app/chain/transfer.py index 29fade83c..2a0c3cbb0 100644 --- a/app/chain/transfer.py +++ b/app/chain/transfer.py @@ -223,7 +223,7 @@ 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: @@ -231,11 +231,9 @@ def __do_transfer(self, fileitem: FileItem, 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: diff --git a/app/modules/filemanager/__init__.py b/app/modules/filemanager/__init__.py index 4b80f2699..dd5157754 100644 --- a/app/modules/filemanager/__init__.py +++ b/app/modules/filemanager/__init__.py @@ -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: