mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-19 16:31:30 +00:00
Move Browser Playwright cache to tmp
Use /a0/tmp/playwright as the Browser plugin Chromium cache and Docker install target while preserving full Chromium installs. Add startup migration cleanup for retired usr Playwright caches, update Browser status/runtime references and docs, and cover migration behavior with focused regressions.
This commit is contained in:
parent
764339b5e7
commit
8b921a8ded
11 changed files with 252 additions and 64 deletions
|
|
@ -0,0 +1,45 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import threading
|
||||
from typing import Any
|
||||
|
||||
from helpers.extension import Extension
|
||||
from helpers.print_style import PrintStyle
|
||||
from plugins._browser import hooks
|
||||
|
||||
|
||||
_startup_migration_thread: threading.Thread | None = None
|
||||
|
||||
|
||||
class BrowserPlaywrightCacheMigration(Extension):
|
||||
def execute(self, **kwargs):
|
||||
_start_background_cache_migration()
|
||||
|
||||
|
||||
def _start_background_cache_migration() -> threading.Thread:
|
||||
global _startup_migration_thread
|
||||
|
||||
if _startup_migration_thread and _startup_migration_thread.is_alive():
|
||||
return _startup_migration_thread
|
||||
|
||||
_startup_migration_thread = threading.Thread(
|
||||
target=_migrate_cache_safely,
|
||||
name="a0-browser-playwright-cache-migration",
|
||||
daemon=True,
|
||||
)
|
||||
_startup_migration_thread.start()
|
||||
return _startup_migration_thread
|
||||
|
||||
|
||||
def _migrate_cache_safely() -> None:
|
||||
try:
|
||||
_log_cache_migration_result(hooks.cleanup_playwright_cache())
|
||||
except Exception as exc:
|
||||
PrintStyle.warning("Browser Playwright cache migration failed:", exc)
|
||||
|
||||
|
||||
def _log_cache_migration_result(result: dict[str, Any]) -> None:
|
||||
if result.get("errors"):
|
||||
PrintStyle.warning("Browser Playwright cache migration reported errors:", result["errors"])
|
||||
elif result.get("migrated") or result.get("removed"):
|
||||
PrintStyle.info("Browser Playwright cache prepared:", result)
|
||||
Loading…
Add table
Add a link
Reference in a new issue