MCPcopy
hub / github.com/MaaEnd/MaaEnd / clean_cache

Function clean_cache

tools/setup_workspace.py:450–469  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

448
449
450def clean_cache() -> None:
451 if not CACHE_DIR.exists():
452 print(Console.info(t("inf_cache_empty")))
453 return
454 total_size = 0
455 count = 0
456 for f in CACHE_DIR.iterdir():
457 if f.is_file():
458 total_size += f.stat().st_size
459 count += 1
460 if count == 0:
461 print(Console.info(t("inf_cache_empty")))
462 return
463 size_mb = total_size / (1024 * 1024)
464 print(Console.info(t("inf_cache_summary", count=count, size=f"{size_mb:.1f} MB")))
465 try:
466 shutil.rmtree(CACHE_DIR)
467 print(Console.ok(t("inf_cache_purged")))
468 except OSError as e:
469 print(Console.warn(t("wrn_cache_clean_failed", path=CACHE_DIR, error=e)))
470
471
472def download_file(

Callers 1

mainFunction · 0.85

Calls 4

infoMethod · 0.80
okMethod · 0.80
warnMethod · 0.80
tFunction · 0.70

Tested by

no test coverage detected