TraceStudio-dev/server/app/utils/io.py
2026-01-09 21:37:02 +08:00

14 lines
391 B
Python

def safe_delete(csv_full_path):
# 自动清理
try:
csv_full_path.unlink()
except Exception as e:
pass
def format_file_size(size_bytes: int) -> str:
"""格式化文件大小"""
for unit in ['B', 'KB', 'MB', 'GB']:
if size_bytes < 1024.0:
return f"{size_bytes:.2f} {unit}"
size_bytes /= 1024.0
return f"{size_bytes:.2f} TB"