Browse Source

remove readalltext

pull/2655/head
Jason Dove 8 months ago
parent
commit
82bda35da5
No known key found for this signature in database
  1. 1
      ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj
  2. 177
      ErsatzTV.Core.Tests/FFmpeg/CustomStreamSelectorTests.cs
  3. 6
      ErsatzTV.Core.Tests/Fakes/FakeLocalFileSystem.cs
  4. 1
      ErsatzTV.Core/ErsatzTV.Core.csproj
  5. 8
      ErsatzTV.Core/FFmpeg/CustomStreamSelector.cs
  6. 1
      ErsatzTV.Core/Interfaces/Metadata/ILocalFileSystem.cs
  7. 1
      ErsatzTV.Core/Metadata/LocalFileSystem.cs
  8. 6
      ErsatzTV.Infrastructure/FFmpeg/MpegTsScriptService.cs
  9. 6
      ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElementLoader.cs
  10. 1
      ErsatzTV.Scanner.Tests/Core/Fakes/FakeLocalFileSystem.cs
  11. 4
      ErsatzTV.Scanner/Program.cs
  12. 4
      ErsatzTV/Startup.cs

1
ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj

@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.2" />
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="Testably.Abstractions.Testing" Version="5.0.0" />
</ItemGroup>
<ItemGroup>

177
ErsatzTV.Core.Tests/FFmpeg/CustomStreamSelectorTests.cs

@ -2,11 +2,11 @@ using Destructurama; @@ -2,11 +2,11 @@ using Destructurama;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.FFmpeg;
using ErsatzTV.Core.Interfaces.FFmpeg;
using ErsatzTV.Core.Tests.Fakes;
using Microsoft.Extensions.Logging;
using NUnit.Framework;
using Serilog;
using Shouldly;
using Testably.Abstractions.Testing;
namespace ErsatzTV.Core.Tests.FFmpeg;
@ -94,9 +94,10 @@ public class CustomStreamSelectorTests @@ -94,9 +94,10 @@ public class CustomStreamSelectorTests
- "eng"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -123,9 +124,10 @@ public class CustomStreamSelectorTests @@ -123,9 +124,10 @@ public class CustomStreamSelectorTests
- audio_language: ["und"]
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -152,9 +154,10 @@ public class CustomStreamSelectorTests @@ -152,9 +154,10 @@ public class CustomStreamSelectorTests
- audio_language: ["en", "eng"]
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -187,9 +190,10 @@ public class CustomStreamSelectorTests @@ -187,9 +190,10 @@ public class CustomStreamSelectorTests
disable_subtitles: true
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -217,9 +221,10 @@ public class CustomStreamSelectorTests @@ -217,9 +221,10 @@ public class CustomStreamSelectorTests
- "en*"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -248,9 +253,10 @@ public class CustomStreamSelectorTests @@ -248,9 +253,10 @@ public class CustomStreamSelectorTests
""";
_audioVersion = GetTestAudioVersion("en");
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -279,9 +285,10 @@ public class CustomStreamSelectorTests @@ -279,9 +285,10 @@ public class CustomStreamSelectorTests
disable_subtitles: true
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -305,9 +312,10 @@ public class CustomStreamSelectorTests @@ -305,9 +312,10 @@ public class CustomStreamSelectorTests
- "eng"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -337,9 +345,10 @@ public class CustomStreamSelectorTests @@ -337,9 +345,10 @@ public class CustomStreamSelectorTests
- "en*"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -378,9 +387,10 @@ public class CustomStreamSelectorTests @@ -378,9 +387,10 @@ public class CustomStreamSelectorTests
}
];
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -413,9 +423,10 @@ public class CustomStreamSelectorTests @@ -413,9 +423,10 @@ public class CustomStreamSelectorTests
disable_subtitles: true
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -450,9 +461,10 @@ public class CustomStreamSelectorTests @@ -450,9 +461,10 @@ public class CustomStreamSelectorTests
disable_subtitles: true
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -492,9 +504,10 @@ public class CustomStreamSelectorTests @@ -492,9 +504,10 @@ public class CustomStreamSelectorTests
disable_subtitles: true
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -528,9 +541,10 @@ public class CustomStreamSelectorTests @@ -528,9 +541,10 @@ public class CustomStreamSelectorTests
disable_subtitles: true
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -568,9 +582,10 @@ public class CustomStreamSelectorTests @@ -568,9 +582,10 @@ public class CustomStreamSelectorTests
- "riff"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -600,9 +615,10 @@ public class CustomStreamSelectorTests @@ -600,9 +615,10 @@ public class CustomStreamSelectorTests
- "movie"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -634,9 +650,10 @@ public class CustomStreamSelectorTests @@ -634,9 +650,10 @@ public class CustomStreamSelectorTests
- "signs"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -668,9 +685,10 @@ public class CustomStreamSelectorTests @@ -668,9 +685,10 @@ public class CustomStreamSelectorTests
- "songs"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -699,9 +717,10 @@ public class CustomStreamSelectorTests @@ -699,9 +717,10 @@ public class CustomStreamSelectorTests
subtitle_condition: "forced"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -730,9 +749,10 @@ public class CustomStreamSelectorTests @@ -730,9 +749,10 @@ public class CustomStreamSelectorTests
subtitle_condition: "lang like 'en%' and external"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -761,9 +781,10 @@ public class CustomStreamSelectorTests @@ -761,9 +781,10 @@ public class CustomStreamSelectorTests
audio_condition: "title like '%movie%'"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -792,9 +813,10 @@ public class CustomStreamSelectorTests @@ -792,9 +813,10 @@ public class CustomStreamSelectorTests
audio_condition: "channels > 2"
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -822,9 +844,10 @@ public class CustomStreamSelectorTests @@ -822,9 +844,10 @@ public class CustomStreamSelectorTests
audio_title_blocklist: ["riff"]
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -853,9 +876,10 @@ public class CustomStreamSelectorTests @@ -853,9 +876,10 @@ public class CustomStreamSelectorTests
subtitle_language: ["jp","en*"]
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,
@ -885,9 +909,10 @@ public class CustomStreamSelectorTests @@ -885,9 +909,10 @@ public class CustomStreamSelectorTests
subtitle_language: ["es*","de*"]
""";
var streamSelector = new CustomStreamSelector(
new FakeLocalFileSystem([new FakeFileEntry(TestFileName) { Contents = YAML }]),
_logger);
var fileSystem = new MockFileSystem();
fileSystem.Initialize()
.WithFile(TestFileName).Which(f => f.HasStringContent(YAML));
var streamSelector = new CustomStreamSelector(fileSystem, _logger);
StreamSelectorResult result = await streamSelector.SelectStreams(
_channel,

6
ErsatzTV.Core.Tests/Fakes/FakeLocalFileSystem.cs

@ -58,12 +58,6 @@ public class FakeLocalFileSystem : ILocalFileSystem @@ -58,12 +58,6 @@ public class FakeLocalFileSystem : ILocalFileSystem
public Unit EmptyFolder(string folder) => Unit.Default;
public async Task<string> ReadAllText(string path) => await _files
.Filter(f => f.Path == path)
.HeadOrNone()
.Select(f => f.Contents)
.IfNoneAsync(string.Empty);
public async Task<string[]> ReadAllLines(string path) => await _files
.Filter(f => f.Path == path)
.HeadOrNone()

1
ErsatzTV.Core/ErsatzTV.Core.csproj

@ -32,6 +32,7 @@ @@ -32,6 +32,7 @@
<PackageReference Include="SkiaSharp" Version="3.119.1" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.119.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-rc.2.25502.107" />
<PackageReference Include="Testably.Abstractions" Version="10.0.0" />
<PackageReference Include="TimeSpanParserUtil" Version="1.2.0" />
<PackageReference Include="YamlDotNet" Version="16.3.0" />
</ItemGroup>

8
ErsatzTV.Core/FFmpeg/CustomStreamSelector.cs

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
using System.IO.Abstractions;
using System.IO.Enumeration;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.FFmpeg.Selector;
using ErsatzTV.Core.Interfaces.FFmpeg;
using ErsatzTV.Core.Interfaces.Metadata;
using Microsoft.Extensions.Logging;
using NCalc;
using YamlDotNet.Serialization;
@ -10,7 +10,7 @@ using YamlDotNet.Serialization.NamingConventions; @@ -10,7 +10,7 @@ using YamlDotNet.Serialization.NamingConventions;
namespace ErsatzTV.Core.FFmpeg;
public class CustomStreamSelector(ILocalFileSystem localFileSystem, ILogger<CustomStreamSelector> logger)
public class CustomStreamSelector(IFileSystem fileSystem, ILogger<CustomStreamSelector> logger)
: ICustomStreamSelector
{
public async Task<StreamSelectorResult> SelectStreams(
@ -25,7 +25,7 @@ public class CustomStreamSelector(ILocalFileSystem localFileSystem, ILogger<Cust @@ -25,7 +25,7 @@ public class CustomStreamSelector(ILocalFileSystem localFileSystem, ILogger<Cust
FileSystemLayout.ChannelStreamSelectorsFolder,
channel.StreamSelector);
if (!localFileSystem.FileExists(streamSelectorFile))
if (!fileSystem.File.Exists(streamSelectorFile))
{
logger.LogWarning("YAML stream selector file {File} does not exist; aborting.", channel.StreamSelector);
return StreamSelectorResult.None;
@ -327,7 +327,7 @@ public class CustomStreamSelector(ILocalFileSystem localFileSystem, ILogger<Cust @@ -327,7 +327,7 @@ public class CustomStreamSelector(ILocalFileSystem localFileSystem, ILogger<Cust
{
try
{
string yaml = await localFileSystem.ReadAllText(streamSelectorFile);
string yaml = await fileSystem.File.ReadAllTextAsync(streamSelectorFile);
IDeserializer deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)

1
ErsatzTV.Core/Interfaces/Metadata/ILocalFileSystem.cs

@ -15,7 +15,6 @@ public interface ILocalFileSystem @@ -15,7 +15,6 @@ public interface ILocalFileSystem
bool FolderExists(string folder);
Task<Either<BaseError, Unit>> CopyFile(string source, string destination);
Unit EmptyFolder(string folder);
Task<string> ReadAllText(string path);
Task<string[]> ReadAllLines(string path);
Task<byte[]> GetHash(string path);
string GetCustomOrDefaultFile(string folder, string file);

1
ErsatzTV.Core/Metadata/LocalFileSystem.cs

@ -184,7 +184,6 @@ public class LocalFileSystem(IClient client, ILogger<LocalFileSystem> logger) : @@ -184,7 +184,6 @@ public class LocalFileSystem(IClient client, ILogger<LocalFileSystem> logger) :
return Unit.Default;
}
public Task<string> ReadAllText(string path) => File.ReadAllTextAsync(path);
public Task<string[]> ReadAllLines(string path) => File.ReadAllLinesAsync(path);
[SuppressMessage("Security", "CA5351:Do Not Use Broken Cryptographic Algorithms")]

6
ErsatzTV.Infrastructure/FFmpeg/MpegTsScriptService.cs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using System.IO.Abstractions;
using System.Runtime.InteropServices;
using CliWrap;
using ErsatzTV.Core;
@ -15,6 +16,7 @@ using YamlDotNet.Serialization.NamingConventions; @@ -15,6 +16,7 @@ using YamlDotNet.Serialization.NamingConventions;
namespace ErsatzTV.Infrastructure.FFmpeg;
public class MpegTsScriptService(
IFileSystem fileSystem,
ILocalFileSystem localFileSystem,
ITempFilePool tempFilePool,
ILogger<MpegTsScriptService> logger) : IMpegTsScriptService
@ -28,7 +30,7 @@ public class MpegTsScriptService( @@ -28,7 +30,7 @@ public class MpegTsScriptService(
string definition = Path.Combine(folder, "mpegts.yml");
if (!Scripts.ContainsKey(folder) && localFileSystem.FileExists(definition))
{
Option<MpegTsScript> maybeScript = FromYaml(await localFileSystem.ReadAllText(definition));
Option<MpegTsScript> maybeScript = FromYaml(await fileSystem.File.ReadAllTextAsync(definition));
foreach (var script in maybeScript)
{
script.Id = Path.GetFileName(folder);
@ -94,7 +96,7 @@ public class MpegTsScriptService( @@ -94,7 +96,7 @@ public class MpegTsScriptService(
string channelName,
string ffmpegPath)
{
string script = await localFileSystem.ReadAllText(fileName);
string script = await fileSystem.File.ReadAllTextAsync(fileName);
try
{
var data = new Dictionary<string, string>

6
ErsatzTV.Infrastructure/Streaming/Graphics/GraphicsElementLoader.cs

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
using System.IO.Abstractions;
using System.Text;
using System.Text.RegularExpressions;
using ErsatzTV.Core.Domain;
@ -18,6 +19,7 @@ namespace ErsatzTV.Infrastructure.Streaming.Graphics; @@ -18,6 +19,7 @@ namespace ErsatzTV.Infrastructure.Streaming.Graphics;
public partial class GraphicsElementLoader(
TemplateFunctions templateFunctions,
IFileSystem fileSystem,
ILocalFileSystem localFileSystem,
ITemplateDataRepository templateDataRepository,
ILogger<GraphicsElementLoader> logger)
@ -147,7 +149,7 @@ public partial class GraphicsElementLoader( @@ -147,7 +149,7 @@ public partial class GraphicsElementLoader(
{
try
{
string yaml = await localFileSystem.ReadAllText(fileName);
string yaml = await fileSystem.File.ReadAllTextAsync(fileName, cancellationToken);
var template = Template.Parse(yaml);
var builder = new StringBuilder();
@ -257,7 +259,7 @@ public partial class GraphicsElementLoader( @@ -257,7 +259,7 @@ public partial class GraphicsElementLoader(
private async Task<Option<string>> GetTemplatedYaml(string fileName, Dictionary<string, object> variables)
{
string yaml = await localFileSystem.ReadAllText(fileName);
string yaml = await fileSystem.File.ReadAllTextAsync(fileName);
try
{
var scriptObject = new ScriptObject();

1
ErsatzTV.Scanner.Tests/Core/Fakes/FakeLocalFileSystem.cs

@ -58,7 +58,6 @@ public class FakeLocalFileSystem : ILocalFileSystem @@ -58,7 +58,6 @@ public class FakeLocalFileSystem : ILocalFileSystem
Task.FromResult(Right<BaseError, Unit>(Unit.Default));
public Unit EmptyFolder(string folder) => Unit.Default;
public Task<string> ReadAllText(string path) => throw new NotImplementedException();
public Task<string[]> ReadAllLines(string path) => throw new NotImplementedException();
public Task<byte[]> GetHash(string path) => throw new NotImplementedException();

4
ErsatzTV.Scanner/Program.cs

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
using System.IO.Abstractions;
using Bugsnag;
using Bugsnag.Payload;
using Dapper;
@ -47,6 +48,7 @@ using Microsoft.IO; @@ -47,6 +48,7 @@ using Microsoft.IO;
using Serilog;
using Serilog.Events;
using Serilog.Formatting.Compact;
using Testably.Abstractions;
using Exception = System.Exception;
using IConfiguration = Bugsnag.IConfiguration;
@ -252,6 +254,8 @@ public class Program @@ -252,6 +254,8 @@ public class Program
services.AddSingleton<IScannerProxy, ScannerProxy>();
services.AddSingleton<ILanguageCodeCache, LanguageCodeCache>();
services.AddSingleton<IFileSystem, RealFileSystem>();
services.AddMediatR(config => config.RegisterServicesFromAssemblyContaining<Worker>());
services.AddMemoryCache();

4
ErsatzTV/Startup.cs

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO.Abstractions;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
@ -99,6 +100,7 @@ using Refit; @@ -99,6 +100,7 @@ using Refit;
using Scalar.AspNetCore;
using Serilog;
using Serilog.Events;
using Testably.Abstractions;
namespace ErsatzTV;
@ -692,6 +694,8 @@ public class Startup @@ -692,6 +694,8 @@ public class Startup
{
services.AddSingleton<IEnvironmentValidator, EnvironmentValidator>();
services.AddSingleton<IFileSystem, RealFileSystem>();
services.AddSingleton<IDatabaseMigrations, DatabaseMigrations>();
services.AddSingleton<IPlexSecretStore, PlexSecretStore>();
services.AddSingleton<IPlexTvApiClient, PlexTvApiClient>(); // TODO: does this need to be singleton?

Loading…
Cancel
Save