fix duplicate logs channel

This commit is contained in:
rambros 2026-03-25 14:07:33 +05:30
parent cefa477459
commit fa0865ef85
2 changed files with 5 additions and 2 deletions

View file

@ -1,14 +1,18 @@
import logging import logging
import asyncio
from src.core.base import MigrationContext from src.core.base import MigrationContext
logger = logging.getLogger(__name__) 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: 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. Logs an event by sending a summary to the `#reaper-logs` audit channel.
If the channel does not exist, it will dynamically create it. 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 # 1. Initialize or Validate channel
channel_id = context.state.audit_log_channel channel_id = context.state.audit_log_channel

View file

@ -21,7 +21,6 @@ class MigrationContext:
# If caller didn't specify, fall back to config value # If caller didn't specify, fall back to config value
self.target_platform = target_platform or config.target_platform or "fluxer" self.target_platform = target_platform or config.target_platform or "fluxer"
self.state = MigrationState() self.state = MigrationState()
self._audit_lock = asyncio.Lock()
# Select the appropriate source reader # Select the appropriate source reader
if source_mode == "backup": if source_mode == "backup":