MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / _is_dir_empty

Method _is_dir_empty

core/storage.py:1051–1061  ·  view source on GitHub ↗

检查目录是否为空

(self, dir_path: str)

Source from the content-addressed store, hash-verified

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 """递归删除空目录"""

Callers 1

_delete_empty_dirsMethod · 0.95

Calls 1

_build_urlMethod · 0.95

Tested by

no test coverage detected