add transfer notification

This commit is contained in:
jxxghp
2023-06-09 15:52:53 +08:00
parent 017fce9e6f
commit 31fe552af4
6 changed files with 102 additions and 15 deletions

View File

@ -97,3 +97,26 @@ class SystemUtils:
files.append(path)
return files
@staticmethod
def get_directory_size(path: Path):
"""
计算目录的大小
参数:
directory_path (Path): 目录路径
返回:
int: 目录的大小(以字节为单位)
"""
if not path or not path.exists():
return 0
if path.is_file():
return path.stat().st_size
total_size = 0
for path in path.glob('**/*'):
if path.is_file():
total_size += path.stat().st_size
return total_size