diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index c8c4da0f7..e0088ab19 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -244,8 +244,6 @@ namespace Emby.Server.Implementations
///
protected readonly SimpleInjector.Container Container = new SimpleInjector.Container();
- protected ISystemEvents SystemEvents { get; set; }
-
///
/// Gets the server configuration manager.
///
@@ -371,7 +369,6 @@ namespace Emby.Server.Implementations
IFileSystem fileSystem,
IEnvironmentInfo environmentInfo,
IImageEncoder imageEncoder,
- ISystemEvents systemEvents,
INetworkManager networkManager)
{
@@ -383,7 +380,6 @@ namespace Emby.Server.Implementations
NetworkManager = networkManager;
networkManager.LocalSubnetsFn = GetConfiguredLocalSubnets;
EnvironmentInfo = environmentInfo;
- SystemEvents = systemEvents;
ApplicationPaths = applicationPaths;
LoggerFactory = loggerFactory;
@@ -762,7 +758,6 @@ namespace Emby.Server.Implementations
RegisterSingleInstance(ApplicationPaths);
RegisterSingleInstance(JsonSerializer);
- RegisterSingleInstance(SystemEvents);
RegisterSingleInstance(LoggerFactory, false);
RegisterSingleInstance(Logger);
@@ -779,7 +774,7 @@ namespace Emby.Server.Implementations
IsoManager = new IsoManager();
RegisterSingleInstance(IsoManager);
- TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, LoggerFactory, FileSystemManager, SystemEvents);
+ TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, LoggerFactory, FileSystemManager);
RegisterSingleInstance(TaskManager);
RegisterSingleInstance(XmlSerializer);
@@ -853,7 +848,7 @@ namespace Emby.Server.Implementations
var musicManager = new MusicManager(LibraryManager);
RegisterSingleInstance(new MusicManager(LibraryManager));
- LibraryMonitor = new LibraryMonitor(LoggerFactory, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, TimerFactory, SystemEvents, EnvironmentInfo);
+ LibraryMonitor = new LibraryMonitor(LoggerFactory, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, TimerFactory, EnvironmentInfo);
RegisterSingleInstance(LibraryMonitor);
RegisterSingleInstance(() => new SearchEngine(LoggerFactory, LibraryManager, UserManager));
diff --git a/Emby.Server.Implementations/EntryPoints/SystemEvents.cs b/Emby.Server.Implementations/EntryPoints/SystemEvents.cs
deleted file mode 100644
index 72c8acd9f..000000000
--- a/Emby.Server.Implementations/EntryPoints/SystemEvents.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using MediaBrowser.Controller;
-using MediaBrowser.Controller.Plugins;
-using MediaBrowser.Model.System;
-
-namespace Emby.Server.Implementations.EntryPoints
-{
- public class SystemEvents : IServerEntryPoint
- {
- private readonly ISystemEvents _systemEvents;
- private readonly IServerApplicationHost _appHost;
-
- public SystemEvents(ISystemEvents systemEvents, IServerApplicationHost appHost)
- {
- _systemEvents = systemEvents;
- _appHost = appHost;
- }
-
- public void Run()
- {
- _systemEvents.SystemShutdown += _systemEvents_SystemShutdown;
- }
-
- private void _systemEvents_SystemShutdown(object sender, EventArgs e)
- {
- _appHost.Shutdown();
- }
-
- public void Dispose()
- {
- _systemEvents.SystemShutdown -= _systemEvents_SystemShutdown;
- }
- }
-}
diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs
index 6a3204011..204f9d949 100644
--- a/Emby.Server.Implementations/IO/LibraryMonitor.cs
+++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs
@@ -140,7 +140,14 @@ namespace Emby.Server.Implementations.IO
///
/// Initializes a new instance of the class.
///
- public LibraryMonitor(ILoggerFactory loggerFactory, ITaskManager taskManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager, IFileSystem fileSystem, ITimerFactory timerFactory, ISystemEvents systemEvents, IEnvironmentInfo environmentInfo)
+ public LibraryMonitor(
+ ILoggerFactory loggerFactory,
+ ITaskManager taskManager,
+ ILibraryManager libraryManager,
+ IServerConfigurationManager configurationManager,
+ IFileSystem fileSystem,
+ ITimerFactory timerFactory,
+ IEnvironmentInfo environmentInfo)
{
if (taskManager == null)
{
@@ -154,26 +161,9 @@ namespace Emby.Server.Implementations.IO
_fileSystem = fileSystem;
_timerFactory = timerFactory;
_environmentInfo = environmentInfo;
-
- systemEvents.Resume += _systemEvents_Resume;
}
- private void _systemEvents_Resume(object sender, EventArgs e)
- {
- Restart();
- }
-
- private void Restart()
- {
- Stop();
-
- if (!_disposed)
- {
- Start();
- }
- }
-
- private bool IsLibraryMonitorEnabaled(BaseItem item)
+ private bool IsLibraryMonitorEnabled(BaseItem item)
{
if (item is BasePluginFolder)
{
@@ -200,7 +190,7 @@ namespace Emby.Server.Implementations.IO
var paths = LibraryManager
.RootFolder
.Children
- .Where(IsLibraryMonitorEnabaled)
+ .Where(IsLibraryMonitorEnabled)
.OfType()
.SelectMany(f => f.PhysicalLocations)
.Distinct(StringComparer.OrdinalIgnoreCase)
@@ -223,7 +213,7 @@ namespace Emby.Server.Implementations.IO
private void StartWatching(BaseItem item)
{
- if (IsLibraryMonitorEnabaled(item))
+ if (IsLibraryMonitorEnabled(item))
{
StartWatchingPath(item.Path);
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index 9e11494c9..4805e54dd 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -60,7 +60,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private readonly IProviderManager _providerManager;
private readonly IMediaEncoder _mediaEncoder;
private readonly IProcessFactory _processFactory;
- private readonly ISystemEvents _systemEvents;
private readonly IAssemblyInfo _assemblyInfo;
private IMediaSourceManager _mediaSourceManager;
@@ -90,8 +89,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
IProviderManager providerManager,
IMediaEncoder mediaEncoder,
ITimerFactory timerFactory,
- IProcessFactory processFactory,
- ISystemEvents systemEvents)
+ IProcessFactory processFactory)
{
Current = this;
@@ -105,7 +103,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_providerManager = providerManager;
_mediaEncoder = mediaEncoder;
_processFactory = processFactory;
- _systemEvents = systemEvents;
_liveTvManager = (LiveTvManager)liveTvManager;
_jsonSerializer = jsonSerializer;
_assemblyInfo = assemblyInfo;
@@ -131,15 +128,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
_timerProvider.RestartTimers();
- _systemEvents.Resume += _systemEvents_Resume;
await CreateRecordingFolders().ConfigureAwait(false);
}
- private void _systemEvents_Resume(object sender, EventArgs e)
- {
- _timerProvider.RestartTimers();
- }
-
private async void OnRecordingFoldersChanged()
{
await CreateRecordingFolders().ConfigureAwait(false);
diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
index 44f6e2d7b..93a9a0d81 100644
--- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
@@ -53,7 +53,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// The task manager.
private ITaskManager TaskManager { get; set; }
private readonly IFileSystem _fileSystem;
- private readonly ISystemEvents _systemEvents;
///
/// Initializes a new instance of the class.
@@ -74,7 +73,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// or
/// logger
///
- public ScheduledTaskWorker(IScheduledTask scheduledTask, IApplicationPaths applicationPaths, ITaskManager taskManager, IJsonSerializer jsonSerializer, ILogger logger, IFileSystem fileSystem, ISystemEvents systemEvents)
+ public ScheduledTaskWorker(IScheduledTask scheduledTask, IApplicationPaths applicationPaths, ITaskManager taskManager, IJsonSerializer jsonSerializer, ILogger logger, IFileSystem fileSystem)
{
if (scheduledTask == null)
{
@@ -103,7 +102,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
JsonSerializer = jsonSerializer;
Logger = logger;
_fileSystem = fileSystem;
- _systemEvents = systemEvents;
InitTriggerEvents();
}
@@ -762,20 +760,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
};
}
- if (info.Type.Equals(typeof(SystemEventTrigger).Name, StringComparison.OrdinalIgnoreCase))
- {
- if (!info.SystemEvent.HasValue)
- {
- throw new ArgumentException("Info did not contain a SystemEvent.", nameof(info));
- }
-
- return new SystemEventTrigger(_systemEvents)
- {
- SystemEvent = info.SystemEvent.Value,
- TaskOptions = options
- };
- }
-
if (info.Type.Equals(typeof(StartupTrigger).Name, StringComparison.OrdinalIgnoreCase))
{
return new StartupTrigger();
diff --git a/Emby.Server.Implementations/ScheduledTasks/SystemEventTrigger.cs b/Emby.Server.Implementations/ScheduledTasks/SystemEventTrigger.cs
deleted file mode 100644
index 7a88fc2b0..000000000
--- a/Emby.Server.Implementations/ScheduledTasks/SystemEventTrigger.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using MediaBrowser.Model.System;
-using MediaBrowser.Model.Tasks;
-using Microsoft.Extensions.Logging;
-
-namespace Emby.Server.Implementations.ScheduledTasks
-{
- ///
- /// Class SystemEventTrigger
- ///
- public class SystemEventTrigger : ITaskTrigger
- {
- ///
- /// Gets or sets the system event.
- ///
- /// The system event.
- public SystemEvent SystemEvent { get; set; }
-
- ///
- /// Gets or sets the options of this task.
- ///
- public TaskOptions TaskOptions { get; set; }
-
- private readonly ISystemEvents _systemEvents;
-
- public SystemEventTrigger(ISystemEvents systemEvents)
- {
- _systemEvents = systemEvents;
- }
-
- ///
- /// Stars waiting for the trigger action
- ///
- /// The last result.
- /// if set to true [is application startup].
- public void Start(TaskResult lastResult, ILogger logger, string taskName, bool isApplicationStartup)
- {
- switch (SystemEvent)
- {
- case SystemEvent.WakeFromSleep:
- _systemEvents.Resume += _systemEvents_Resume;
- break;
- }
- }
-
- private async void _systemEvents_Resume(object sender, EventArgs e)
- {
- if (SystemEvent == SystemEvent.WakeFromSleep)
- {
- // This value is a bit arbitrary, but add a delay to help ensure network connections have been restored before running the task
- await Task.Delay(10000).ConfigureAwait(false);
-
- OnTriggered();
- }
- }
-
- ///
- /// Stops waiting for the trigger action
- ///
- public void Stop()
- {
- _systemEvents.Resume -= _systemEvents_Resume;
- }
-
- ///
- /// Occurs when [triggered].
- ///
- public event EventHandler Triggered;
-
- ///
- /// Called when [triggered].
- ///
- private void OnTriggered()
- {
- if (Triggered != null)
- {
- Triggered(this, EventArgs.Empty);
- }
- }
- }
-}
diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
index 02a082d3f..d74c8fe8c 100644
--- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs
@@ -46,8 +46,6 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// The application paths.
private IApplicationPaths ApplicationPaths { get; set; }
- private readonly ISystemEvents _systemEvents;
-
///
/// Gets the logger.
///
@@ -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 lines;
-
- try
- {
- lines = _fileSystem.ReadAllLines(path).ToList();
- }
- catch
- {
- lines = new List();
- }
-
- 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();
}
diff --git a/Emby.Server.Implementations/SystemEvents.cs b/Emby.Server.Implementations/SystemEvents.cs
deleted file mode 100644
index e4c54c3c5..000000000
--- a/Emby.Server.Implementations/SystemEvents.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using MediaBrowser.Model.System;
-
-namespace Emby.Server.Implementations
-{
- public class SystemEvents : ISystemEvents
- {
- public event EventHandler Resume;
- public event EventHandler Suspend;
- public event EventHandler SessionLogoff;
- public event EventHandler SystemShutdown;
- }
-}
diff --git a/Jellyfin.Server/CoreAppHost.cs b/Jellyfin.Server/CoreAppHost.cs
index 6832fe743..b580f45ca 100644
--- a/Jellyfin.Server/CoreAppHost.cs
+++ b/Jellyfin.Server/CoreAppHost.cs
@@ -11,8 +11,8 @@ namespace Jellyfin.Server
{
public class CoreAppHost : ApplicationHost
{
- public CoreAppHost(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory, StartupOptions options, IFileSystem fileSystem, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager)
- : base(applicationPaths, loggerFactory, options, fileSystem, environmentInfo, imageEncoder, systemEvents, networkManager)
+ public CoreAppHost(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory, StartupOptions options, IFileSystem fileSystem, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, MediaBrowser.Common.Net.INetworkManager networkManager)
+ : base(applicationPaths, loggerFactory, options, fileSystem, environmentInfo, imageEncoder, networkManager)
{
}
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index c196a3f23..f64f50cd7 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -96,7 +96,6 @@ namespace Jellyfin.Server
fileSystem,
environmentInfo,
new NullImageEncoder(),
- new SystemEvents(),
new NetworkManager(_loggerFactory, environmentInfo)))
{
appHost.Init();
diff --git a/MediaBrowser.Model/System/ISystemEvents.cs b/MediaBrowser.Model/System/ISystemEvents.cs
deleted file mode 100644
index 8c47d6fbf..000000000
--- a/MediaBrowser.Model/System/ISystemEvents.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-
-namespace MediaBrowser.Model.System
-{
- public interface ISystemEvents
- {
- event EventHandler Resume;
- event EventHandler Suspend;
- event EventHandler SessionLogoff;
- event EventHandler SystemShutdown;
- }
-}
diff --git a/MediaBrowser.Model/Tasks/ITaskManager.cs b/MediaBrowser.Model/Tasks/ITaskManager.cs
index a7c2f6d86..57b8d1af8 100644
--- a/MediaBrowser.Model/Tasks/ITaskManager.cs
+++ b/MediaBrowser.Model/Tasks/ITaskManager.cs
@@ -72,7 +72,5 @@ namespace MediaBrowser.Model.Tasks
event EventHandler> TaskExecuting;
event EventHandler TaskCompleted;
-
- void RunTaskOnNextStartup(string key);
}
}
diff --git a/MediaBrowser.Model/Tasks/SystemEvent.cs b/MediaBrowser.Model/Tasks/SystemEvent.cs
deleted file mode 100644
index 5a3d8a8eb..000000000
--- a/MediaBrowser.Model/Tasks/SystemEvent.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace MediaBrowser.Model.Tasks
-{
- ///
- /// Enum SystemEvent
- ///
- public enum SystemEvent
- {
- ///
- /// The wake from sleep
- ///
- WakeFromSleep = 0
- }
-}
diff --git a/MediaBrowser.Model/Tasks/TaskTriggerInfo.cs b/MediaBrowser.Model/Tasks/TaskTriggerInfo.cs
index 80101ec48..714f11872 100644
--- a/MediaBrowser.Model/Tasks/TaskTriggerInfo.cs
+++ b/MediaBrowser.Model/Tasks/TaskTriggerInfo.cs
@@ -25,12 +25,6 @@ namespace MediaBrowser.Model.Tasks
/// The interval.
public long? IntervalTicks { get; set; }
- ///
- /// Gets or sets the system event.
- ///
- /// The system event.
- public SystemEvent? SystemEvent { get; set; }
-
///
/// Gets or sets the day of week.
///