mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 00:55:13 +01:00
added a notifications service
This commit is contained in:
@@ -512,24 +512,6 @@ namespace MediaBrowser.Common.Implementations
|
||||
Plugins = list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs the pending restart.
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
public void PerformPendingRestart()
|
||||
{
|
||||
if (HasPendingRestart)
|
||||
{
|
||||
Logger.Info("Restarting the application");
|
||||
|
||||
Restart();
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Info("PerformPendingRestart - not needed");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies that the kernel that a change has been made that requires a restart
|
||||
/// </summary>
|
||||
|
||||
@@ -343,6 +343,8 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||
TaskCompletionStatus status;
|
||||
CurrentExecutionStartTime = DateTime.UtcNow;
|
||||
|
||||
Exception failureException = null;
|
||||
|
||||
try
|
||||
{
|
||||
await ExecuteTask(CurrentCancellationTokenSource.Token, progress).ConfigureAwait(false);
|
||||
@@ -357,6 +359,8 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||
{
|
||||
Logger.ErrorException("Error", ex);
|
||||
|
||||
failureException = ex;
|
||||
|
||||
status = TaskCompletionStatus.Failed;
|
||||
}
|
||||
|
||||
@@ -368,7 +372,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||
CurrentCancellationTokenSource = null;
|
||||
CurrentProgress = null;
|
||||
|
||||
OnTaskCompleted(startTime, endTime, status);
|
||||
OnTaskCompleted(startTime, endTime, status, failureException);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -517,7 +521,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||
/// <param name="startTime">The start time.</param>
|
||||
/// <param name="endTime">The end time.</param>
|
||||
/// <param name="status">The status.</param>
|
||||
private void OnTaskCompleted(DateTime startTime, DateTime endTime, TaskCompletionStatus status)
|
||||
private void OnTaskCompleted(DateTime startTime, DateTime endTime, TaskCompletionStatus status, Exception ex)
|
||||
{
|
||||
var elapsedTime = endTime - startTime;
|
||||
|
||||
@@ -532,6 +536,11 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||
Id = Id
|
||||
};
|
||||
|
||||
if (ex != null)
|
||||
{
|
||||
result.ErrorMessage = ex.Message;
|
||||
}
|
||||
|
||||
JsonSerializer.SerializeToFile(result, GetHistoryFilePath(true));
|
||||
|
||||
LastExecutionResult = result;
|
||||
@@ -560,7 +569,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||
|
||||
if (State == TaskState.Running)
|
||||
{
|
||||
OnTaskCompleted(CurrentExecutionStartTime, DateTime.UtcNow, TaskCompletionStatus.Aborted);
|
||||
OnTaskCompleted(CurrentExecutionStartTime, DateTime.UtcNow, TaskCompletionStatus.Aborted, null);
|
||||
}
|
||||
|
||||
if (CurrentCancellationTokenSource != null)
|
||||
|
||||
@@ -21,10 +21,10 @@ namespace MediaBrowser.Common.Implementations.Updates
|
||||
/// </summary>
|
||||
public class InstallationManager : IInstallationManager
|
||||
{
|
||||
public event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstalling;
|
||||
public event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstallationCompleted;
|
||||
public event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstallationFailed;
|
||||
public event EventHandler<GenericEventArgs<InstallationInfo>> PackageInstallationCancelled;
|
||||
public event EventHandler<InstallationEventArgs> PackageInstalling;
|
||||
public event EventHandler<InstallationEventArgs> PackageInstallationCompleted;
|
||||
public event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed;
|
||||
public event EventHandler<InstallationEventArgs> PackageInstallationCancelled;
|
||||
|
||||
/// <summary>
|
||||
/// The current installations
|
||||
@@ -384,7 +384,13 @@ namespace MediaBrowser.Common.Implementations.Updates
|
||||
|
||||
var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, innerCancellationTokenSource.Token).Token;
|
||||
|
||||
EventHelper.QueueEventIfNotNull(PackageInstalling, this, new GenericEventArgs<InstallationInfo> { Argument = installationInfo }, _logger);
|
||||
var installationEventArgs = new InstallationEventArgs
|
||||
{
|
||||
InstallationInfo = installationInfo,
|
||||
PackageVersionInfo = package
|
||||
};
|
||||
|
||||
EventHelper.QueueEventIfNotNull(PackageInstalling, this, installationEventArgs, _logger);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -397,7 +403,7 @@ namespace MediaBrowser.Common.Implementations.Updates
|
||||
|
||||
CompletedInstallations.Add(installationInfo);
|
||||
|
||||
EventHelper.QueueEventIfNotNull(PackageInstallationCompleted, this, new GenericEventArgs<InstallationInfo> { Argument = installationInfo }, _logger);
|
||||
EventHelper.QueueEventIfNotNull(PackageInstallationCompleted, this, installationEventArgs, _logger);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
@@ -408,7 +414,7 @@ namespace MediaBrowser.Common.Implementations.Updates
|
||||
|
||||
_logger.Info("Package installation cancelled: {0} {1}", package.name, package.versionStr);
|
||||
|
||||
EventHelper.QueueEventIfNotNull(PackageInstallationCancelled, this, new GenericEventArgs<InstallationInfo> { Argument = installationInfo }, _logger);
|
||||
EventHelper.QueueEventIfNotNull(PackageInstallationCancelled, this, installationEventArgs, _logger);
|
||||
|
||||
throw;
|
||||
}
|
||||
@@ -421,7 +427,12 @@ namespace MediaBrowser.Common.Implementations.Updates
|
||||
CurrentInstallations.Remove(tuple);
|
||||
}
|
||||
|
||||
EventHelper.QueueEventIfNotNull(PackageInstallationFailed, this, new GenericEventArgs<InstallationInfo> { Argument = installationInfo }, _logger);
|
||||
EventHelper.QueueEventIfNotNull(PackageInstallationFailed, this, new InstallationFailedEventArgs
|
||||
{
|
||||
InstallationInfo = installationInfo,
|
||||
Exception = ex
|
||||
|
||||
}, _logger);
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user