From e7500d586c0fa3436cd996071e449b2fa174c7eb Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Wed, 13 Mar 2013 14:36:27 -0400 Subject: [PATCH 1/3] #7 - Initial library scan being cancelled --- .../ScheduledTasks/TaskManager.cs | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs index 61e1f63299..0f3bae87c8 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs @@ -106,7 +106,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks /// The task. private void QueueScheduledTask(IScheduledTaskWorker task) { - var type = task.GetType(); + var type = task.ScheduledTask.GetType(); lock (_taskQueue) { @@ -173,14 +173,46 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks return ((ScheduledTaskWorker)task).Execute(); } + /// + /// Called when [task executing]. + /// + /// The task. internal void OnTaskExecuting(IScheduledTask task) { EventHelper.QueueEventIfNotNull(TaskExecuting, task, EventArgs.Empty, Logger); } + /// + /// Called when [task completed]. + /// + /// The task. + /// The result. internal void OnTaskCompleted(IScheduledTask task, TaskResult result) { EventHelper.QueueEventIfNotNull(TaskExecuting, task, new GenericEventArgs { Argument = result }, Logger); + ExecuteQueuedTasks(); + } + + /// + /// Executes the queued tasks. + /// + private void ExecuteQueuedTasks() + { + // Execute queued tasks + lock (_taskQueue) + { + foreach (var type in _taskQueue.ToList()) + { + var scheduledTask = ScheduledTasks.First(t => t.ScheduledTask.GetType() == type); + + if (scheduledTask.State == TaskState.Idle) + { + ((ScheduledTaskWorker)scheduledTask).Execute(); + + _taskQueue.Remove(type); + } + } + } } } } From 3dc9cacfad034b11e8ddfb37b24b15499190c6bf Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Wed, 13 Mar 2013 16:23:46 -0400 Subject: [PATCH 2/3] #51 - Restart the server took long time, and dashboard will die --- MediaBrowser.ServerApplication/App.xaml.cs | 5 +++++ MediaBrowser.WebDashboard/Html/scripts/site.js | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.ServerApplication/App.xaml.cs b/MediaBrowser.ServerApplication/App.xaml.cs index 0155d0c90e..35f203a629 100644 --- a/MediaBrowser.ServerApplication/App.xaml.cs +++ b/MediaBrowser.ServerApplication/App.xaml.cs @@ -134,6 +134,11 @@ namespace MediaBrowser.ServerApplication Logger.ErrorException("UnhandledException", exception); MessageBox.Show("Unhandled exception: " + exception.Message); + + if (!Debugger.IsAttached) + { + Environment.Exit(System.Runtime.InteropServices.Marshal.GetHRForException(exception)); + } } /// diff --git a/MediaBrowser.WebDashboard/Html/scripts/site.js b/MediaBrowser.WebDashboard/Html/scripts/site.js index 7ecaff85bf..cb4ba3bdd5 100644 --- a/MediaBrowser.WebDashboard/Html/scripts/site.js +++ b/MediaBrowser.WebDashboard/Html/scripts/site.js @@ -382,7 +382,7 @@ var Dashboard = { setTimeout(function () { Dashboard.reloadPageWhenServerAvailable(); - }, 500); + }, 250); }).fail(function () { Dashboard.suppressAjaxErrors = false; @@ -391,10 +391,17 @@ var Dashboard = { reloadPageWhenServerAvailable: function (retryCount) { - ApiClient.getSystemInfo().done(function () { - Dashboard.reloadPage(); + ApiClient.getSystemInfo().done(function (info) { + + // If this is back to false, the restart completed + if (!info.HasPendingRestart) { + Dashboard.reloadPage(); + } else { + Dashboard.reloadPageWhenServerAvailable(retryCount); + } }).fail(function () { + setTimeout(function () { retryCount = retryCount || 0; From 2ca20eeefcfbd0258a76f4139a8ba68971cf2434 Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Wed, 13 Mar 2013 16:57:19 -0400 Subject: [PATCH 3/3] fixed dashboard reporting issue --- .../Api/DashboardInfoWebSocketListener.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.WebDashboard/Api/DashboardInfoWebSocketListener.cs b/MediaBrowser.WebDashboard/Api/DashboardInfoWebSocketListener.cs index 5fc1f75c5d..6109f73bbb 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardInfoWebSocketListener.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardInfoWebSocketListener.cs @@ -43,12 +43,13 @@ namespace MediaBrowser.WebDashboard.Api /// The logger. /// The task manager. /// The user manager. - public DashboardInfoWebSocketListener(IServerApplicationHost appHost, ILogger logger, ITaskManager taskManager, IUserManager userManager) + public DashboardInfoWebSocketListener(IServerApplicationHost appHost, ILogger logger, ITaskManager taskManager, IUserManager userManager, ILibraryManager libraryManager) : base(logger) { _appHost = appHost; _taskManager = taskManager; _userManager = userManager; + _libraryManager = libraryManager; } ///