mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-29 20:08:27 +01:00
isolated clickonce dependancies
This commit is contained in:
@@ -171,7 +171,7 @@ namespace MediaBrowser.Common.ScheduledTasks
|
||||
/// Gets the current progress.
|
||||
/// </summary>
|
||||
/// <value>The current progress.</value>
|
||||
public TaskProgress CurrentProgress { get; private set; }
|
||||
public double? CurrentProgress { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The _triggers
|
||||
@@ -246,7 +246,7 @@ namespace MediaBrowser.Common.ScheduledTasks
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <returns>Task.</returns>
|
||||
protected abstract Task ExecuteInternal(CancellationToken cancellationToken, IProgress<TaskProgress> progress);
|
||||
protected abstract Task ExecuteInternal(CancellationToken cancellationToken, IProgress<double> progress);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the task
|
||||
@@ -355,7 +355,7 @@ namespace MediaBrowser.Common.ScheduledTasks
|
||||
|
||||
Logger.Info("Executing {0}", Name);
|
||||
|
||||
var progress = new Progress<TaskProgress>();
|
||||
var progress = new Progress<double>();
|
||||
|
||||
progress.ProgressChanged += progress_ProgressChanged;
|
||||
|
||||
@@ -426,7 +426,7 @@ namespace MediaBrowser.Common.ScheduledTasks
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The e.</param>
|
||||
void progress_ProgressChanged(object sender, TaskProgress e)
|
||||
void progress_ProgressChanged(object sender, double e)
|
||||
{
|
||||
CurrentProgress = e;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace MediaBrowser.Common.ScheduledTasks
|
||||
/// Gets the current progress.
|
||||
/// </summary>
|
||||
/// <value>The current progress.</value>
|
||||
TaskProgress CurrentProgress { get; }
|
||||
double? CurrentProgress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the task
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace MediaBrowser.Common.ScheduledTasks
|
||||
return new TaskInfo
|
||||
{
|
||||
Name = task.Name,
|
||||
CurrentProgress = task.CurrentProgress,
|
||||
CurrentProgressPercentage = task.CurrentProgress,
|
||||
State = task.State,
|
||||
Id = task.Id,
|
||||
LastExecutionResult = task.LastExecutionResult,
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <returns>Task.</returns>
|
||||
protected override Task ExecuteInternal(CancellationToken cancellationToken, IProgress<TaskProgress> progress)
|
||||
protected override Task ExecuteInternal(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
@@ -51,7 +51,7 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
/// <param name="directory">The directory.</param>
|
||||
/// <param name="minDateModified">The min date modified.</param>
|
||||
/// <param name="progress">The progress.</param>
|
||||
private void DeleteCacheFilesFromDirectory(CancellationToken cancellationToken, string directory, DateTime minDateModified, IProgress<TaskProgress> progress)
|
||||
private void DeleteCacheFilesFromDirectory(CancellationToken cancellationToken, string directory, DateTime minDateModified, IProgress<double> progress)
|
||||
{
|
||||
var filesToDelete = new DirectoryInfo(directory).EnumerateFileSystemInfos("*", SearchOption.AllDirectories)
|
||||
.Where(f => !f.Attributes.HasFlag(FileAttributes.Directory) && f.LastWriteTimeUtc < minDateModified)
|
||||
@@ -64,7 +64,7 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
double percent = index;
|
||||
percent /= filesToDelete.Count;
|
||||
|
||||
progress.Report(new TaskProgress { Description = file.FullName, PercentComplete = 100 * percent });
|
||||
progress.Report(100 * percent);
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
index++;
|
||||
}
|
||||
|
||||
progress.Report(new TaskProgress { PercentComplete = 100 });
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <returns>Task.</returns>
|
||||
protected override Task ExecuteInternal(CancellationToken cancellationToken, IProgress<TaskProgress> progress)
|
||||
protected override Task ExecuteInternal(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
@@ -51,7 +51,7 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
double percent = index;
|
||||
percent /= filesToDelete.Count;
|
||||
|
||||
progress.Report(new TaskProgress { Description = file.FullName, PercentComplete = 100 * percent });
|
||||
progress.Report(100 * percent);
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
index++;
|
||||
}
|
||||
|
||||
progress.Report(new TaskProgress { PercentComplete = 100 });
|
||||
progress.Report(100);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <returns>Task.</returns>
|
||||
protected override Task ExecuteInternal(CancellationToken cancellationToken, IProgress<TaskProgress> progress)
|
||||
protected override Task ExecuteInternal(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
progress.Report(new TaskProgress { PercentComplete = 0 });
|
||||
progress.Report(0);
|
||||
|
||||
return Task.Run(() => Kernel.ReloadLogger());
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.Updates;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Deployment.Application;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -16,6 +13,21 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
[Export(typeof(IScheduledTask))]
|
||||
public class SystemUpdateTask : BaseScheduledTask<IKernel>
|
||||
{
|
||||
/// <summary>
|
||||
/// The _app host
|
||||
/// </summary>
|
||||
private readonly IApplicationHost _appHost;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SystemUpdateTask" /> class.
|
||||
/// </summary>
|
||||
/// <param name="appHost">The app host.</param>
|
||||
[ImportingConstructor]
|
||||
public SystemUpdateTask([Import("appHost")] IApplicationHost appHost)
|
||||
{
|
||||
_appHost = appHost;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the triggers that define when the task will run
|
||||
/// </summary>
|
||||
@@ -37,26 +49,26 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <returns>Task.</returns>
|
||||
protected override async Task ExecuteInternal(CancellationToken cancellationToken, IProgress<TaskProgress> progress)
|
||||
protected override async Task ExecuteInternal(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
if (!ApplicationDeployment.IsNetworkDeployed) return;
|
||||
if (!_appHost.CanSelfUpdate) return;
|
||||
|
||||
EventHandler<TaskProgress> innerProgressHandler = (sender, e) => progress.Report(new TaskProgress { PercentComplete = e.PercentComplete * .1 });
|
||||
EventHandler<double> innerProgressHandler = (sender, e) => progress.Report(e * .1);
|
||||
|
||||
// Create a progress object for the update check
|
||||
var innerProgress = new Progress<TaskProgress>();
|
||||
var innerProgress = new Progress<double>();
|
||||
innerProgress.ProgressChanged += innerProgressHandler;
|
||||
|
||||
var updateInfo = await new ApplicationUpdateCheck().CheckForApplicationUpdate(cancellationToken, innerProgress).ConfigureAwait(false);
|
||||
var updateInfo = await _appHost.CheckForApplicationUpdate(cancellationToken, innerProgress).ConfigureAwait(false);
|
||||
|
||||
// Release the event handler
|
||||
innerProgress.ProgressChanged -= innerProgressHandler;
|
||||
|
||||
progress.Report(new TaskProgress { PercentComplete = 10 });
|
||||
progress.Report(10);
|
||||
|
||||
if (!updateInfo.UpdateAvailable)
|
||||
if (!updateInfo.IsUpdateAvailable)
|
||||
{
|
||||
progress.Report(new TaskProgress { PercentComplete = 100 });
|
||||
progress.Report(100);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,12 +78,12 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
{
|
||||
Logger.Info("Update Revision {0} available. Updating...", updateInfo.AvailableVersion);
|
||||
|
||||
innerProgressHandler = (sender, e) => progress.Report(new TaskProgress { PercentComplete = (e.PercentComplete * .9) + .1 });
|
||||
innerProgressHandler = (sender, e) => progress.Report((e * .9) + .1);
|
||||
|
||||
innerProgress = new Progress<TaskProgress>();
|
||||
innerProgress = new Progress<double>();
|
||||
innerProgress.ProgressChanged += innerProgressHandler;
|
||||
|
||||
await new ApplicationUpdater().UpdateApplication(cancellationToken, innerProgress).ConfigureAwait(false);
|
||||
await _appHost.UpdateApplication(cancellationToken, innerProgress).ConfigureAwait(false);
|
||||
|
||||
// Release the event handler
|
||||
innerProgress.ProgressChanged -= innerProgressHandler;
|
||||
@@ -83,7 +95,7 @@ namespace MediaBrowser.Common.ScheduledTasks.Tasks
|
||||
Logger.Info("A new version of Media Browser is available.");
|
||||
}
|
||||
|
||||
progress.Report(new TaskProgress { PercentComplete = 100 });
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user