递归删除空目录
(self, file_path: str, session: aiohttp.ClientSession)
| 1061 | return content.count("<D:response>") <= 1 |
| 1062 | |
| 1063 | async def _delete_empty_dirs(self, file_path: str, session: aiohttp.ClientSession): |
| 1064 | """递归删除空目录""" |
| 1065 | path_obj = Path(file_path) |
| 1066 | current_path = path_obj.parent |
| 1067 | |
| 1068 | while str(current_path) != ".": |
| 1069 | if not await self._is_dir_empty(str(current_path)): |
| 1070 | break |
| 1071 | |
| 1072 | url = self._build_url(str(current_path)) |
| 1073 | async with session.delete(url) as resp: |
| 1074 | if resp.status not in (200, 204, 404): |
| 1075 | break |
| 1076 | |
| 1077 | current_path = current_path.parent |
| 1078 | |
| 1079 | async def save_file(self, file: UploadFile, save_path: str): |
| 1080 | """保存文件(自动创建目录,流式上传)""" |
no test coverage detected