Spaces:
Running
Running
Download scripts/cleanup_ttl.py from 2Btainment/spaceforge: direct link, hf CLI and curl.
- Browser
- Download file 531 Bytes
-
https://huggingface.co/spaces/2Btainment/spaceforge/resolve/main/scripts/cleanup_ttl.py
- Command line
-
hf download hf://spaces/2Btainment/spaceforge/scripts/cleanup_ttl.py
-
curl -L -o cleanup_ttl.py https://huggingface.co/spaces/2Btainment/spaceforge/resolve/main/scripts/cleanup_ttl.py
531 Bytes
| #!/usr/bin/env python3 | |
| """Optional cron helper: purge expired build dirs.""" | |
| from __future__ import annotations | |
| import shutil | |
| import time | |
| from pathlib import Path | |
| TTL = 3600 | |
| ROOT = Path("/data/builds") if Path("/data/builds").exists() else Path("/tmp/spaceforge/builds") | |
| def main() -> None: | |
| if not ROOT.exists(): | |
| return | |
| now = time.time() | |
| for d in ROOT.iterdir(): | |
| if d.is_dir() and now - d.stat().st_mtime > TTL: | |
| shutil.rmtree(d, ignore_errors=True) | |
| if __name__ == "__main__": | |
| main() | |