fix(api): apply schedule-file update before daily rebuild time in PUT /api/playouts/{id} (#170 review)
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 4m24s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 4m38s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped

A rejected scripted schedule file no longer leaves DailyRebuildTime
half-applied; the file update is the only fallible step post-pre-check.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 17:30:38 +02:00
co-authored by Claude Fable 5
parent 15f2beb7f9
commit f06bc064a0
+18 -15
View File
@@ -148,25 +148,28 @@ public class PlayoutController(IMediator mediator) : ControllerBase
}
}
// the schedule-file update is the only step that can fail after the pre-checks,
// so it goes first — a rejected file must not leave DailyRebuildTime applied
if (hasScheduleFile)
{
foreach (PlayoutNameViewModel playout in maybePlayout)
{
Either<BaseError, PlayoutNameViewModel> scheduleFileResult =
await UpdateScheduleFile(playout, request.ScheduleFile, cancellationToken);
foreach (BaseError error in scheduleFileResult.LeftToSeq())
{
return error.ToErrorResult();
}
}
}
Option<TimeSpan> dailyRebuildTime = request.DailyRebuildTime is { } t ? Some(t) : Option<TimeSpan>.None;
Either<BaseError, PlayoutNameViewModel> result =
await mediator.Send(new UpdatePlayout(id, dailyRebuildTime), cancellationToken);
return await result.Match(
Left: error => Task.FromResult(error.ToErrorResult()),
Right: async playout =>
{
if (!hasScheduleFile)
{
return (IActionResult)new OkObjectResult(ToResponse(playout));
}
Either<BaseError, PlayoutNameViewModel> scheduleFileResult =
await UpdateScheduleFile(playout, request.ScheduleFile, cancellationToken);
return scheduleFileResult.Match(
Left: error => error.ToErrorResult(),
Right: updated => (IActionResult)new OkObjectResult(ToResponse(updated)));
});
return result.Match(
Left: error => error.ToErrorResult(),
Right: playout => (IActionResult)new OkObjectResult(ToResponse(playout)));
}
private async Task<Either<BaseError, PlayoutNameViewModel>> UpdateScheduleFile(