diff --git a/src/LiveRecorder.Application/Services/RecordService.cs b/src/LiveRecorder.Application/Services/RecordService.cs index 148a4eb..7c200fd 100644 --- a/src/LiveRecorder.Application/Services/RecordService.cs +++ b/src/LiveRecorder.Application/Services/RecordService.cs @@ -126,9 +126,17 @@ public sealed class RecordService throw new InvalidOperationException("The live room is disabled. Enable it before starting a recording."); } + await ReconcileActiveSessionsAsync(liveRoom.Id, cancellationToken); var activeSession = await _recordSessionRepository.GetActiveByLiveRoomIdAsync(liveRoom.Id, cancellationToken); if (activeSession is not null) { + await _systemLogService.WriteAsync( + SystemLogLevel.Warning, + "RecordSession", + "Recording start skipped because an active session still exists after reconciliation.", + liveRoomId: liveRoom.Id, + recordSessionId: activeSession.Id, + cancellationToken: cancellationToken); throw new InvalidOperationException("An active recording session already exists for the live room."); } diff --git a/src/LiveRecorder.Infrastructure/Services/LiveRoomPollingBackgroundService.cs b/src/LiveRecorder.Infrastructure/Services/LiveRoomPollingBackgroundService.cs index c97ef47..bfdaba0 100644 --- a/src/LiveRecorder.Infrastructure/Services/LiveRoomPollingBackgroundService.cs +++ b/src/LiveRecorder.Infrastructure/Services/LiveRoomPollingBackgroundService.cs @@ -216,6 +216,12 @@ public sealed class LiveRoomPollingBackgroundService : BackgroundService if (hasRunningSession) { + await logService.WriteAsync( + SystemLogLevel.Info, + "Scheduler", + "Auto-start skipped because an active recording session already exists.", + liveRoomId: liveRoom.Id, + cancellationToken: cancellationToken); return; }