Remove ActionableProgress
This commit is contained in:
parent
8698b90594
commit
0960438065
|
@ -22,7 +22,6 @@ using Jellyfin.Data.Entities;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Extensions;
|
using Jellyfin.Extensions;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Progress;
|
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
|
@ -1048,18 +1047,14 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
await ValidateTopLibraryFolders(cancellationToken).ConfigureAwait(false);
|
await ValidateTopLibraryFolders(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var innerProgress = new ActionableProgress<double>();
|
var innerProgress = new Progress<double>(pct => progress.Report(pct * 0.96));
|
||||||
|
|
||||||
innerProgress.RegisterAction(pct => progress.Report(pct * 0.96));
|
|
||||||
|
|
||||||
// Validate the entire media library
|
// Validate the entire media library
|
||||||
await RootFolder.ValidateChildren(innerProgress, new MetadataRefreshOptions(new DirectoryService(_fileSystem)), recursive: true, cancellationToken).ConfigureAwait(false);
|
await RootFolder.ValidateChildren(innerProgress, new MetadataRefreshOptions(new DirectoryService(_fileSystem)), recursive: true, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
progress.Report(96);
|
progress.Report(96);
|
||||||
|
|
||||||
innerProgress = new ActionableProgress<double>();
|
innerProgress = new Progress<double>(pct => progress.Report(96 + (pct * .04)));
|
||||||
|
|
||||||
innerProgress.RegisterAction(pct => progress.Report(96 + (pct * .04)));
|
|
||||||
|
|
||||||
await RunPostScanTasks(innerProgress, cancellationToken).ConfigureAwait(false);
|
await RunPostScanTasks(innerProgress, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -1081,12 +1076,10 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
foreach (var task in tasks)
|
foreach (var task in tasks)
|
||||||
{
|
{
|
||||||
var innerProgress = new ActionableProgress<double>();
|
|
||||||
|
|
||||||
// Prevent access to modified closure
|
// Prevent access to modified closure
|
||||||
var currentNumComplete = numComplete;
|
var currentNumComplete = numComplete;
|
||||||
|
|
||||||
innerProgress.RegisterAction(pct =>
|
var innerProgress = new Progress<double>(pct =>
|
||||||
{
|
{
|
||||||
double innerPercent = pct;
|
double innerPercent = pct;
|
||||||
innerPercent /= 100;
|
innerPercent /= 100;
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
#pragma warning disable CA1003
|
|
||||||
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Progress
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Class ActionableProgress.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The type for the action parameter.</typeparam>
|
|
||||||
public class ActionableProgress<T> : IProgress<T>
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The _actions.
|
|
||||||
/// </summary>
|
|
||||||
private Action<T>? _action;
|
|
||||||
|
|
||||||
public event EventHandler<T>? ProgressChanged;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Registers the action.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="action">The action.</param>
|
|
||||||
public void RegisterAction(Action<T> action)
|
|
||||||
{
|
|
||||||
_action = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Report(T value)
|
|
||||||
{
|
|
||||||
ProgressChanged?.Invoke(this, value);
|
|
||||||
|
|
||||||
_action?.Invoke(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -13,7 +13,6 @@ using System.Threading.Tasks.Dataflow;
|
||||||
using Jellyfin.Data.Entities;
|
using Jellyfin.Data.Entities;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Extensions;
|
using Jellyfin.Extensions;
|
||||||
using MediaBrowser.Common.Progress;
|
|
||||||
using MediaBrowser.Controller.Channels;
|
using MediaBrowser.Controller.Channels;
|
||||||
using MediaBrowser.Controller.Collections;
|
using MediaBrowser.Controller.Collections;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
@ -429,10 +428,8 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
if (recursive)
|
if (recursive)
|
||||||
{
|
{
|
||||||
var innerProgress = new ActionableProgress<double>();
|
|
||||||
|
|
||||||
var folder = this;
|
var folder = this;
|
||||||
innerProgress.RegisterAction(innerPercent =>
|
var innerProgress = new Progress<double>(innerPercent =>
|
||||||
{
|
{
|
||||||
var percent = ProgressHelpers.GetProgress(ProgressHelpers.UpdatedChildItems, ProgressHelpers.ScannedSubfolders, innerPercent);
|
var percent = ProgressHelpers.GetProgress(ProgressHelpers.UpdatedChildItems, ProgressHelpers.ScannedSubfolders, innerPercent);
|
||||||
|
|
||||||
|
@ -461,10 +458,8 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
var container = this as IMetadataContainer;
|
var container = this as IMetadataContainer;
|
||||||
|
|
||||||
var innerProgress = new ActionableProgress<double>();
|
|
||||||
|
|
||||||
var folder = this;
|
var folder = this;
|
||||||
innerProgress.RegisterAction(innerPercent =>
|
var innerProgress = new Progress<double>(innerPercent =>
|
||||||
{
|
{
|
||||||
var percent = ProgressHelpers.GetProgress(ProgressHelpers.ScannedSubfolders, ProgressHelpers.RefreshedMetadata, innerPercent);
|
var percent = ProgressHelpers.GetProgress(ProgressHelpers.ScannedSubfolders, ProgressHelpers.RefreshedMetadata, innerPercent);
|
||||||
|
|
||||||
|
@ -572,9 +567,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
var actionBlock = new ActionBlock<int>(
|
var actionBlock = new ActionBlock<int>(
|
||||||
async i =>
|
async i =>
|
||||||
{
|
{
|
||||||
var innerProgress = new ActionableProgress<double>();
|
var innerProgress = new Progress<double>(innerPercent =>
|
||||||
|
|
||||||
innerProgress.RegisterAction(innerPercent =>
|
|
||||||
{
|
{
|
||||||
// round the percent and only update progress if it changed to prevent excessive UpdateProgress calls
|
// round the percent and only update progress if it changed to prevent excessive UpdateProgress calls
|
||||||
var innerPercentRounded = Math.Round(innerPercent);
|
var innerPercentRounded = Math.Round(innerPercent);
|
||||||
|
|
|
@ -7,7 +7,6 @@ using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Extensions;
|
using Jellyfin.Extensions;
|
||||||
using Jellyfin.LiveTv.Configuration;
|
using Jellyfin.LiveTv.Configuration;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Progress;
|
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
@ -108,8 +107,7 @@ public class GuideManager : IGuideManager
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var innerProgress = new ActionableProgress<double>();
|
var innerProgress = new Progress<double>(p => progress.Report(p * progressPerService));
|
||||||
innerProgress.RegisterAction(p => progress.Report(p * progressPerService));
|
|
||||||
|
|
||||||
var idList = await RefreshChannelsInternal(service, innerProgress, cancellationToken).ConfigureAwait(false);
|
var idList = await RefreshChannelsInternal(service, innerProgress, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -158,7 +156,7 @@ public class GuideManager : IGuideManager
|
||||||
: 7;
|
: 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Tuple<List<Guid>, List<Guid>>> RefreshChannelsInternal(ILiveTvService service, ActionableProgress<double> progress, CancellationToken cancellationToken)
|
private async Task<Tuple<List<Guid>, List<Guid>>> RefreshChannelsInternal(ILiveTvService service, IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
progress.Report(10);
|
progress.Report(10);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user