Merge pull request #10969 from barronpm/progress-cleanup

Progress cleanup
This commit is contained in:
Bond-009
2024-02-07 16:24:36 +01:00
committed by GitHub
23 changed files with 44 additions and 448 deletions

View File

@@ -9,7 +9,6 @@ using System.Text.Json.Serialization;
using System.Threading;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Querying;
@@ -53,7 +52,7 @@ namespace MediaBrowser.Controller.Channels
query.ChannelIds = new Guid[] { Id };
// Don't blow up here because it could cause parent screens with other content to fail
return ChannelManager.GetChannelItemsInternal(query, new SimpleProgress<double>(), CancellationToken.None).GetAwaiter().GetResult();
return ChannelManager.GetChannelItemsInternal(query, new Progress<double>(), CancellationToken.None).GetAwaiter().GetResult();
}
catch
{

View File

@@ -1,42 +0,0 @@
#pragma warning disable CA1711, CS1591
using System;
using System.IO;
using MediaBrowser.Model.Drawing;
namespace MediaBrowser.Controller.Drawing
{
public class ImageStream : IDisposable
{
public ImageStream(Stream stream)
{
Stream = stream;
}
/// <summary>
/// Gets the stream.
/// </summary>
/// <value>The stream.</value>
public Stream Stream { get; }
/// <summary>
/// Gets or sets the format.
/// </summary>
/// <value>The format.</value>
public ImageFormat Format { get; set; }
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
Stream?.Dispose();
}
}
}
}

View File

@@ -13,7 +13,6 @@ using System.Threading.Tasks.Dataflow;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Collections;
using MediaBrowser.Controller.Configuration;
@@ -429,16 +428,22 @@ namespace MediaBrowser.Controller.Entities
if (recursive)
{
var innerProgress = new ActionableProgress<double>();
var folder = this;
innerProgress.RegisterAction(innerPercent =>
var innerProgress = new Progress<double>(innerPercent =>
{
var percent = ProgressHelpers.GetProgress(ProgressHelpers.UpdatedChildItems, ProgressHelpers.ScannedSubfolders, innerPercent);
progress.Report(percent);
ProviderManager.OnRefreshProgress(folder, percent);
// TODO: this is sometimes being called after the refresh has completed.
try
{
ProviderManager.OnRefreshProgress(folder, percent);
}
catch (InvalidOperationException e)
{
Logger.LogError(e, "Error refreshing folder");
}
});
if (validChildrenNeedGeneration)
@@ -461,10 +466,8 @@ namespace MediaBrowser.Controller.Entities
var container = this as IMetadataContainer;
var innerProgress = new ActionableProgress<double>();
var folder = this;
innerProgress.RegisterAction(innerPercent =>
var innerProgress = new Progress<double>(innerPercent =>
{
var percent = ProgressHelpers.GetProgress(ProgressHelpers.ScannedSubfolders, ProgressHelpers.RefreshedMetadata, innerPercent);
@@ -472,7 +475,15 @@ namespace MediaBrowser.Controller.Entities
if (recursive)
{
ProviderManager.OnRefreshProgress(folder, percent);
// TODO: this is sometimes being called after the refresh has completed.
try
{
ProviderManager.OnRefreshProgress(folder, percent);
}
catch (InvalidOperationException e)
{
Logger.LogError(e, "Error refreshing folder");
}
}
});
@@ -572,9 +583,7 @@ namespace MediaBrowser.Controller.Entities
var actionBlock = new ActionBlock<int>(
async i =>
{
var innerProgress = new ActionableProgress<double>();
innerProgress.RegisterAction(innerPercent =>
var innerProgress = new Progress<double>(innerPercent =>
{
// round the percent and only update progress if it changed to prevent excessive UpdateProgress calls
var innerPercentRounded = Math.Round(innerPercent);
@@ -922,7 +931,7 @@ namespace MediaBrowser.Controller.Entities
query.ChannelIds = new[] { ChannelId };
// Don't blow up here because it could cause parent screens with other content to fail
return ChannelManager.GetChannelItemsInternal(query, new SimpleProgress<double>(), CancellationToken.None).GetAwaiter().GetResult();
return ChannelManager.GetChannelItemsInternal(query, new Progress<double>(), CancellationToken.None).GetAwaiter().GetResult();
}
catch
{

View File

@@ -1,23 +0,0 @@
#nullable disable
#pragma warning disable CS1591
namespace MediaBrowser.Controller.MediaEncoding
{
public class ImageEncodingOptions
{
public string InputPath { get; set; }
public int? Width { get; set; }
public int? Height { get; set; }
public int? MaxWidth { get; set; }
public int? MaxHeight { get; set; }
public int? Quality { get; set; }
public string Format { get; set; }
}
}

View File

@@ -1,11 +0,0 @@
#pragma warning disable CS1591
namespace MediaBrowser.Controller.MediaEncoding
{
/// <summary>
/// Class MediaEncoderHelpers.
/// </summary>
public static class MediaEncoderHelpers
{
}
}