Spaces:
Runtime error
Runtime error
| import os | |
| import shutil | |
| import logging | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger("Cleaner") | |
| def deep_clean(): | |
| # Daftar folder yang sering bikin penuh | |
| targets = [ | |
| "temp_dir", # Folder sementara download | |
| "saved_model/temp", # Folder sisa ekstraksi | |
| "~/.cache/huggingface" # Cache utama HF (ini yang paling besar biasanya) | |
| ] | |
| logger.info("🧹 Memulai pembersihan cache...") | |
| for target in targets: | |
| path = os.path.expanduser(target) | |
| if os.path.exists(path): | |
| try: | |
| shutil.rmtree(path) | |
| logger.info(f"✅ Berhasil menghapus: {path}") | |
| except Exception as e: | |
| logger.error(f"❌ Gagal menghapus {path}: {e}") | |
| else: | |
| logger.info(f"ℹ️ Folder tidak ditemukan (sudah bersih): {path}") | |
| logger.info("✨ Semua sampah sudah dibersihkan!") | |
| if __name__ == "__main__": | |
| deep_clean() |