diff --git a/src/core/audit.py b/src/core/audit.py index 7529f69..0a86fc5 100644 --- a/src/core/audit.py +++ b/src/core/audit.py @@ -1,14 +1,18 @@ import logging +import asyncio from src.core.base import MigrationContext logger = logging.getLogger(__name__) +# Shared lock to prevent concurrent audit channel setup across different context instances +_setup_lock = asyncio.Lock() + async def log_audit_event(context: MigrationContext, title: str, description: str, files: list[dict] | None = None) -> None: """ Logs an event by sending a summary to the `#reaper-logs` audit channel. If the channel does not exist, it will dynamically create it. """ - async with context._audit_lock: + async with _setup_lock: # 1. Initialize or Validate channel channel_id = context.state.audit_log_channel diff --git a/src/core/base.py b/src/core/base.py index ee7b56d..87086b1 100644 --- a/src/core/base.py +++ b/src/core/base.py @@ -21,7 +21,6 @@ class MigrationContext: # If caller didn't specify, fall back to config value self.target_platform = target_platform or config.target_platform or "fluxer" self.state = MigrationState() - self._audit_lock = asyncio.Lock() # Select the appropriate source reader if source_mode == "backup":