检查目录是否为空
(self, dir_path: str)
| 1049 | ) |
| 1050 | |
| 1051 | async def _is_dir_empty(self, dir_path: str) -> bool: |
| 1052 | """检查目录是否为空""" |
| 1053 | url = self._build_url(dir_path) |
| 1054 | |
| 1055 | async with aiohttp.ClientSession(auth=self.auth) as session: |
| 1056 | async with session.request("PROPFIND", url, headers={"Depth": "1"}) as resp: |
| 1057 | if resp.status != 207: # 207 是 Multi-Status 响应 |
| 1058 | return False |
| 1059 | content = await resp.text() |
| 1060 | # 如果只有一个 response(当前目录),说明目录为空 |
| 1061 | return content.count("<D:response>") <= 1 |
| 1062 | |
| 1063 | async def _delete_empty_dirs(self, file_path: str, session: aiohttp.ClientSession): |
| 1064 | """递归删除空目录""" |
no test coverage detected