Browse Source

fix scripted schedule validation (#2377)

pull/2378/head
Jason Dove 4 months ago committed by GitHub
parent
commit
0d82e0234b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 5
      ErsatzTV.Application/Playouts/Commands/CreateScriptedPlayoutHandler.cs
  3. 24
      ErsatzTV.Application/Playouts/Commands/UpdateScriptedPlayoutHandler.cs

1
CHANGELOG.md

@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Fixed
- Fix transcoding content with bt709/pc color metadata
- Fix scripted schedule validation (file exists) when creating or editing playout
### Changed
- **BREAKING CHANGE**: change how `Scripted Schedule` system works

5
ErsatzTV.Application/Playouts/Commands/CreateScriptedPlayoutHandler.cs

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
using System.CommandLine.Parsing;
using System.Threading.Channels;
using ErsatzTV.Application.Channels;
using ErsatzTV.Core;
@ -88,7 +89,9 @@ public class CreateScriptedPlayoutHandler @@ -88,7 +89,9 @@ public class CreateScriptedPlayoutHandler
private Validation<BaseError, string> ValidateScheduleFile(CreateScriptedPlayout request)
{
if (!_localFileSystem.FileExists(request.ScheduleFile))
var args = CommandLineParser.SplitCommandLine(request.ScheduleFile).ToList();
string scriptFile = args[0];
if (!_localFileSystem.FileExists(scriptFile))
{
return BaseError.New("Scripted schedule does not exist!");
}

24
ErsatzTV.Application/Playouts/Commands/UpdateScriptedPlayoutHandler.cs

@ -1,7 +1,9 @@ @@ -1,7 +1,9 @@
using System.Threading.Channels;
using System.CommandLine.Parsing;
using System.Threading.Channels;
using ErsatzTV.Application.Channels;
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Metadata;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
@ -11,7 +13,8 @@ namespace ErsatzTV.Application.Playouts; @@ -11,7 +13,8 @@ namespace ErsatzTV.Application.Playouts;
public class
UpdateScriptedPlayoutHandler(
IDbContextFactory<TvContext> dbContextFactory,
ChannelWriter<IBackgroundServiceRequest> workerChannel)
ChannelWriter<IBackgroundServiceRequest> workerChannel,
ILocalFileSystem localFileSystem)
: IRequestHandler<UpdateScriptedPlayout,
Either<BaseError, PlayoutNameViewModel>>
{
@ -48,11 +51,24 @@ public class @@ -48,11 +51,24 @@ public class
playout.DailyRebuildTime);
}
private static Task<Validation<BaseError, Playout>> Validate(
private async Task<Validation<BaseError, Playout>> Validate(
TvContext dbContext,
UpdateScriptedPlayout request,
CancellationToken cancellationToken) =>
PlayoutMustExist(dbContext, request, cancellationToken);
(ValidateScheduleFile(request), await PlayoutMustExist(dbContext, request, cancellationToken))
.Apply((_, playout) => playout);
private Validation<BaseError, string> ValidateScheduleFile(UpdateScriptedPlayout request)
{
var args = CommandLineParser.SplitCommandLine(request.ScheduleFile).ToList();
string scriptFile = args[0];
if (!localFileSystem.FileExists(scriptFile))
{
return BaseError.New("Scripted schedule does not exist!");
}
return request.ScheduleFile;
}
private static Task<Validation<BaseError, Playout>> PlayoutMustExist(
TvContext dbContext,

Loading…
Cancel
Save