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

Method _delete_empty_dirs

core/storage.py:1063–1077  ·  view source on GitHub ↗

递归删除空目录

(self, file_path: str, session: aiohttp.ClientSession)

Source from the content-addressed store, hash-verified

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 """保存文件(自动创建目录,流式上传)"""

Callers 1

delete_fileMethod · 0.95

Calls 3

_is_dir_emptyMethod · 0.95
_build_urlMethod · 0.95
deleteMethod · 0.80

Tested by

no test coverage detected