refactor: 统一临时文件清理逻辑

This commit is contained in:
2026-06-01 18:29:24 +08:00
parent c061b66169
commit 118c5b1ab7
4 changed files with 21 additions and 20 deletions
+7 -1
View File
@@ -1,6 +1,13 @@
from pathlib import Path
def remove_file_safely(path: Path) -> None:
try:
path.unlink()
except OSError:
pass
def get_dir_size(path: Path) -> int:
total_size = 0
try:
@@ -26,4 +33,3 @@ def format_size(size_bytes: int) -> str:
return f"{value:.2f} {unit}"
value /= 1024.0
return f"{value:.2f} PB"