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

Method clean_chunks

core/storage.py:230–248  ·  view source on GitHub ↗

清理本地文件系统的临时分片文件 :param upload_id: 上传会话ID :param save_path: 文件保存路径

(self, upload_id: str, save_path: str)

Source from the content-addressed store, hash-verified

228 return str(output_path), file_sha256.hexdigest()
229
230 async def clean_chunks(self, upload_id: str, save_path: str):
231 """
232 清理本地文件系统的临时分片文件
233 :param upload_id: 上传会话ID
234 :param save_path: 文件保存路径
235 """
236 chunk_dir = (self.root_path / save_path).parent / 'chunks' / upload_id
237 if chunk_dir.exists():
238 try:
239 shutil.rmtree(chunk_dir)
240 except Exception as e:
241 logger.info(f"清理本地分片目录失败: {e}")
242 # 清理父级 chunks 目录(如果为空)
243 chunks_parent = chunk_dir.parent
244 if chunks_parent.exists() and not any(chunks_parent.iterdir()):
245 try:
246 chunks_parent.rmdir()
247 except Exception as e:
248 logger.info(f"清理 chunks 父目录失败: {e}")
249
250 async def file_exists(self, save_path: str) -> bool:
251 """

Callers

nothing calls this directly

Calls 1

existsMethod · 0.80

Tested by

no test coverage detected