Spaces:
Runtime error
Runtime error
File size: 977 Bytes
e59cf3b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 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() |