From 4d6ed7d5521857fc1f15a5c79528f1997ab26e11 Mon Sep 17 00:00:00 2001 From: Attente <19653207+wikrin@users.noreply.github.com> Date: Mon, 28 Oct 2024 08:31:32 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=B0=86=E8=AE=A1=E7=AE=97=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=AD=E6=89=80=E6=9C=89=E6=96=87=E4=BB=B6=E6=80=BB?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E7=A7=BB=E5=8A=A8=E5=88=B0=20`modules.filema?= =?UTF-8?q?nager`=20=E6=A8=A1=E5=9D=97=E4=B8=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/transfer.py | 6 ++---- app/modules/filemanager/__init__.py | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) 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: