| 448 | |
| 449 | |
| 450 | def 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 | |
| 472 | def download_file( |