* flag local movies as file not found * show warning icon on cards * unflag movie that is found during scan * skip missing files when building playouts * add state to search index * add file not found health check * link to search from file not found health check * support flagging other media kinds as file not found * continue to schedule missing items * support episode files not found * wip trash page * fix trash url * trash page is functional * update changelog * fix changelog merge
59 lines
2.0 KiB
C#
59 lines
2.0 KiB
C#
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Threading.Tasks;
|
|
using ErsatzTV.Core.Health;
|
|
using Lucene.Net.Util;
|
|
using static LanguageExt.Prelude;
|
|
|
|
namespace ErsatzTV.Infrastructure.Health.Checks
|
|
{
|
|
public abstract class BaseHealthCheck
|
|
{
|
|
protected abstract string Title { get; }
|
|
|
|
protected HealthCheckResult Result(HealthCheckStatus status, string message) =>
|
|
new(Title, status, message, None);
|
|
|
|
protected HealthCheckResult NotApplicableResult() =>
|
|
new(Title, HealthCheckStatus.NotApplicable, string.Empty, None);
|
|
|
|
protected HealthCheckResult OkResult() =>
|
|
new(Title, HealthCheckStatus.Pass, string.Empty, None);
|
|
|
|
protected HealthCheckResult FailResult(string message) =>
|
|
new(Title, HealthCheckStatus.Fail, message, None);
|
|
|
|
protected HealthCheckResult WarningResult(string message) =>
|
|
new(Title, HealthCheckStatus.Warning, message, None);
|
|
|
|
protected HealthCheckResult WarningResult(string message, string link) =>
|
|
new(Title, HealthCheckStatus.Warning, message, link);
|
|
|
|
protected HealthCheckResult InfoResult(string message) =>
|
|
new(Title, HealthCheckStatus.Info, message, None);
|
|
|
|
protected static async Task<string> GetProcessOutput(string path, IEnumerable<string> arguments)
|
|
{
|
|
var startInfo = new ProcessStartInfo
|
|
{
|
|
FileName = path,
|
|
RedirectStandardOutput = true,
|
|
RedirectStandardError = true,
|
|
UseShellExecute = false
|
|
};
|
|
|
|
startInfo.ArgumentList.AddRange(arguments);
|
|
|
|
var process = new Process
|
|
{
|
|
StartInfo = startInfo
|
|
};
|
|
|
|
process.Start();
|
|
string result = await process.StandardOutput.ReadToEndAsync();
|
|
await process.WaitForExitAsync();
|
|
return result;
|
|
}
|
|
}
|
|
}
|