update to handle new structure from spectra, no more gobs (#1266)

This commit is contained in:
NotSoToothless
2026-05-23 17:16:53 -07:00
committed by GitHub
parent 2d5adfcbe0
commit f6f4e33a65
11 changed files with 459 additions and 313 deletions
+4 -7
View File
@@ -285,14 +285,14 @@ async def cleanup_replays():
"""
Cleans up replay directories in STORAGE/REPLAYS/:
- After 12 hours: deletes regenerable files (PNGs, MP4s)
- After 48 hours: deletes entire directory (GOB + JSON included)
- After 48 hours: deletes entire directory (replay JSON included)
Age is determined from the mtime of replay.gob / replay_data.json (written
Age is determined from the mtime of replay_data.json (written
once at capture time), not the directory mtime — directory mtime is bumped
whenever files inside are added or removed (including by this cleanup), which
would otherwise keep dirs perpetually "fresh".
"""
KEEP_FILES = {"replay.gob", "replay_data.json"}
KEEP_FILES = {"replay_data.json"}
def _sync_cleanup_replays():
"""Synchronous helper that walks replay dirs and deletes stale files."""
@@ -312,11 +312,8 @@ async def cleanup_replays():
if not entry_path.is_dir():
continue
gob_path = entry_path / "replay.gob"
json_path = entry_path / "replay_data.json"
if gob_path.exists():
entry_mtime = gob_path.stat().st_mtime
elif json_path.exists():
if json_path.exists():
entry_mtime = json_path.stat().st_mtime
else:
entry_mtime = entry_path.stat().st_mtime