MCPcopy Index your code
hub / github.com/google/adk-python / cleanup_tmp

Function cleanup_tmp

src/google/adk/cli/fast_api.py:229–263  ·  view source on GitHub ↗
(app_name: str)

Source from the content-addressed store, hash-verified

227 shutil.copy2(source_path, dest_path)
228
229 def cleanup_tmp(app_name: str) -> bool:
230 try:
231 app_root = _get_app_root(app_name)
232 except ValueError as exc:
233 logger.exception("Error in cleanup_tmp: %s", exc)
234 return False
235
236 try:
237 tmp_agent_root = _get_tmp_agent_root(app_root, app_name)
238 except ValueError as exc:
239 logger.exception("Error in cleanup_tmp: %s", exc)
240 return False
241
242 try:
243 shutil.rmtree(tmp_agent_root)
244 except FileNotFoundError:
245 pass
246 except OSError as exc:
247 logger.exception("Error deleting tmp agent root: %s", exc)
248 return False
249
250 tmp_dir = app_root / "tmp"
251 resolved_tmp_dir = tmp_dir.resolve()
252 if not resolved_tmp_dir.is_relative_to(app_root):
253 logger.error(
254 "Refusing to delete tmp outside app_root: %s", resolved_tmp_dir
255 )
256 return False
257
258 try:
259 tmp_dir.rmdir()
260 except OSError:
261 pass
262
263 return True
264
265 def ensure_tmp_exists(app_name: str) -> bool:
266 try:

Callers 4

builder_buildMethod · 0.85
builder_cancelMethod · 0.85
builder_buildFunction · 0.85
builder_cancelFunction · 0.85

Calls 4

_get_app_rootFunction · 0.85
_get_tmp_agent_rootFunction · 0.85
resolveMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected