fix: reconcile sessions before auto-start
This commit is contained in:
@@ -126,9 +126,17 @@ public sealed class RecordService
|
|||||||
throw new InvalidOperationException("The live room is disabled. Enable it before starting a recording.");
|
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);
|
var activeSession = await _recordSessionRepository.GetActiveByLiveRoomIdAsync(liveRoom.Id, cancellationToken);
|
||||||
if (activeSession is not null)
|
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.");
|
throw new InvalidOperationException("An active recording session already exists for the live room.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,6 +216,12 @@ public sealed class LiveRoomPollingBackgroundService : BackgroundService
|
|||||||
|
|
||||||
if (hasRunningSession)
|
if (hasRunningSession)
|
||||||
{
|
{
|
||||||
|
await logService.WriteAsync(
|
||||||
|
SystemLogLevel.Info,
|
||||||
|
"Scheduler",
|
||||||
|
"Auto-start skipped because an active recording session already exists.",
|
||||||
|
liveRoomId: liveRoom.Id,
|
||||||
|
cancellationToken: cancellationToken);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user