mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 18:11:16 +01:00
- Bulk /download endpoint now caches ZIPs for Range requests (max 100 ROMs)
- LRU eviction frees space by removing oldest cached ZIPs (>1h old)
- Tiered TTL: 48h default, 12h for ZIPs over 8GB
- Generalize cache paths from rom_id to namespace (supports bulk-{ids})
29 lines
858 B
Python
29 lines
858 B
Python
from logger.logger import log
|
|
from tasks.tasks import PeriodicTask, TaskType
|
|
from utils.zip_cache import cleanup_stale_zips
|
|
|
|
|
|
class CleanupZipCacheTask(PeriodicTask):
|
|
def __init__(self):
|
|
super().__init__(
|
|
title="Scheduled ZIP cache cleanup",
|
|
description="Removes stale cached ZIP files based on tiered TTL",
|
|
task_type=TaskType.CLEANUP,
|
|
enabled=True,
|
|
manual_run=False,
|
|
cron_string="0 4 * * *",
|
|
func="tasks.scheduled.cleanup_zip_cache.cleanup_zip_cache_task.run",
|
|
)
|
|
|
|
async def run(self) -> None:
|
|
if not self.enabled:
|
|
self.unschedule()
|
|
return
|
|
|
|
deleted = cleanup_stale_zips()
|
|
if deleted:
|
|
log.info(f"Cleaned up {deleted} stale cached ZIP files")
|
|
|
|
|
|
cleanup_zip_cache_task = CleanupZipCacheTask()
|