Spaces:
Running
Running
File size: 531 Bytes
3806142 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #!/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()
|