Fresh start - excluded large ROM JSON files

This commit is contained in:
OpenClaw Agent
2026-04-11 09:45:12 -05:00
commit 5deb387aa6
395 changed files with 47744 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
"""Session Archive Weekly
Archives old session files from openclaw data directory.
"""
import os
import shutil
from datetime import datetime, timedelta
from pathlib import Path
# Paths
DATA_DIR = Path(os.environ.get("OPENCLAW_DATA", os.path.expanduser("~/.openclaw")))
ARCHIVE_DIR = DATA_DIR / "workspace" / "memory" / "archive"
def archive_old_sessions():
"""Archive session files older than 7 days."""
ARCHIVE_DIR.mkdir(parents=True, exist_ok=True)
cutoff = datetime.now() - timedelta(days=7)
archived_count = 0
# Archive old session logs if they exist
session_dir = DATA_DIR / "sessions"
if session_dir.exists():
for f in session_dir.glob("**/*.json"):
if datetime.fromtimestamp(f.stat().st_mtime) < cutoff:
dest = ARCHIVE_DIR / f.name
if not dest.exists():
shutil.copy2(f, dest)
archived_count += 1
print(f"Archived {archived_count} old session files")
return archived_count
if __name__ == "__main__":
count = archive_old_sessions()
print(f"[OK] Weekly archive complete - {count} files archived")