JoeanAmier 7cedd8d4b8 feat: 新增文件断点续传功能
1. 新增自动删除空文件夹功能
2. 引入 aiofiles 库
3. 修正 Actions 错误

Closes #142
Closes #143
2024-08-07 22:10:15 +08:00

22 lines
479 B
Python

from pathlib import Path
def file_switch(path: Path) -> None:
if path.exists():
path.unlink()
else:
path.touch()
def remove_empty_directories(path: Path) -> None:
exclude = {
"\\.",
"\\_",
"\\__",
}
for dir_path, dir_names, file_names in path.walk(top_down=False, ):
if any(i in str(dir_path) for i in exclude):
continue
if not dir_names and not file_names:
dir_path.rmdir()