aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-02-03 15:52:45 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-02-03 15:55:00 -0500
commitfb2a320416d2b7437a483f6f5ecc42e6f67ff91c (patch)
tree19aeda1815891b2df1b79453b6892883cd37ccc4 /MediaBrowser.Common.Implementations
parent4fc3753f6498351589daa9101bfe98148a57ce42 (diff)
update upgrade process
Diffstat (limited to 'MediaBrowser.Common.Implementations')
-rw-r--r--MediaBrowser.Common.Implementations/BaseApplicationHost.cs6
-rw-r--r--MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs53
2 files changed, 55 insertions, 4 deletions
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index 2a93efcde..caf8f54a6 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -453,7 +453,7 @@ namespace MediaBrowser.Common.Implementations
RegisterSingleInstance<IApplicationPaths>(ApplicationPaths);
- TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, Logger, FileSystemManager);
+ TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, LogManager.GetLogger("TaskManager"), FileSystemManager);
RegisterSingleInstance(JsonSerializer);
RegisterSingleInstance(XmlSerializer);
@@ -465,7 +465,7 @@ namespace MediaBrowser.Common.Implementations
RegisterSingleInstance(FileSystemManager);
- HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger, FileSystemManager);
+ HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, LogManager.GetLogger("HttpClient"), FileSystemManager);
RegisterSingleInstance(HttpClient);
NetworkManager = CreateNetworkManager(LogManager.GetLogger("NetworkManager"));
@@ -474,7 +474,7 @@ namespace MediaBrowser.Common.Implementations
SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LogManager);
RegisterSingleInstance(SecurityManager);
- InstallationManager = new InstallationManager(Logger, this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager);
+ InstallationManager = new InstallationManager(LogManager.GetLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager);
RegisterSingleInstance(InstallationManager);
ZipClient = new ZipClient(FileSystemManager);
diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs
index 845c984fb..b5566650c 100644
--- a/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs
+++ b/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs
@@ -55,6 +55,25 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
private ILogger Logger { get; set; }
private readonly IFileSystem _fileSystem;
+ private bool _suspendTriggers;
+
+ public bool SuspendTriggers
+ {
+ get { return _suspendTriggers; }
+ set
+ {
+ Logger.Info("Setting SuspendTriggers to {0}", value);
+ var executeQueued = _suspendTriggers && !value;
+
+ _suspendTriggers = value;
+
+ if (executeQueued)
+ {
+ ExecuteQueuedTasks();
+ }
+ }
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="TaskManager" /> class.
/// </summary>
@@ -151,6 +170,31 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
QueueScheduledTask<T>(new TaskExecutionOptions());
}
+ public void Execute<T>()
+ where T : IScheduledTask
+ {
+ var scheduledTask = ScheduledTasks.FirstOrDefault(t => t.ScheduledTask.GetType() == typeof(T));
+
+ if (scheduledTask == null)
+ {
+ Logger.Error("Unable to find scheduled task of type {0} in Execute.", typeof(T).Name);
+ }
+ else
+ {
+ var type = scheduledTask.ScheduledTask.GetType();
+
+ Logger.Info("Queueing task {0}", type.Name);
+
+ lock (_taskQueue)
+ {
+ if (scheduledTask.State == TaskState.Idle)
+ {
+ Execute(scheduledTask, new TaskExecutionOptions());
+ }
+ }
+ }
+ }
+
/// <summary>
/// Queues the scheduled task.
/// </summary>
@@ -183,7 +227,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
lock (_taskQueue)
{
- if (task.State == TaskState.Idle)
+ if (task.State == TaskState.Idle && !SuspendTriggers)
{
Execute(task, options);
return;
@@ -273,6 +317,13 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// </summary>
private void ExecuteQueuedTasks()
{
+ if (SuspendTriggers)
+ {
+ return;
+ }
+
+ Logger.Info("ExecuteQueuedTasks");
+
// Execute queued tasks
lock (_taskQueue)
{