Remove remnants of system events

This commit is contained in:
Bond_009
2019-01-25 22:41:43 +01:00
parent e0315b5695
commit fd7f420af2
14 changed files with 19 additions and 264 deletions

View File

@@ -46,8 +46,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// <value>The application paths.</value>
private IApplicationPaths ApplicationPaths { get; set; }
private readonly ISystemEvents _systemEvents;
/// <summary>
/// Gets the logger.
/// </summary>
@@ -66,54 +64,16 @@ namespace Emby.Server.Implementations.ScheduledTasks
IApplicationPaths applicationPaths,
IJsonSerializer jsonSerializer,
ILoggerFactory loggerFactory,
IFileSystem fileSystem,
ISystemEvents systemEvents)
IFileSystem fileSystem)
{
ApplicationPaths = applicationPaths;
JsonSerializer = jsonSerializer;
Logger = loggerFactory.CreateLogger(nameof(TaskManager));
_fileSystem = fileSystem;
_systemEvents = systemEvents;
ScheduledTasks = new IScheduledTaskWorker[] { };
}
private void BindToSystemEvent()
{
_systemEvents.Resume += _systemEvents_Resume;
}
private void _systemEvents_Resume(object sender, EventArgs e)
{
foreach (var task in ScheduledTasks)
{
task.ReloadTriggerEvents();
}
}
public void RunTaskOnNextStartup(string key)
{
var path = Path.Combine(ApplicationPaths.CachePath, "startuptasks.txt");
List<string> lines;
try
{
lines = _fileSystem.ReadAllLines(path).ToList();
}
catch
{
lines = new List<string>();
}
if (!lines.Contains(key, StringComparer.OrdinalIgnoreCase))
{
lines.Add(key);
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
_fileSystem.WriteAllLines(path, lines);
}
}
private void RunStartupTasks()
{
var path = Path.Combine(ApplicationPaths.CachePath, "startuptasks.txt");
@@ -290,12 +250,10 @@ namespace Emby.Server.Implementations.ScheduledTasks
var myTasks = ScheduledTasks.ToList();
var list = tasks.ToList();
myTasks.AddRange(list.Select(t => new ScheduledTaskWorker(t, ApplicationPaths, this, JsonSerializer, Logger, _fileSystem, _systemEvents)));
myTasks.AddRange(list.Select(t => new ScheduledTaskWorker(t, ApplicationPaths, this, JsonSerializer, Logger, _fileSystem)));
ScheduledTasks = myTasks.ToArray();
BindToSystemEvent();
RunStartupTasks();
}