mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-10 20:26:17 +00:00
update wizard function of enable/disable local metadata saving
This commit is contained in:
@@ -38,24 +38,13 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// Gets or sets the postscan tasks.
|
||||
/// </summary>
|
||||
/// <value>The postscan tasks.</value>
|
||||
private IEnumerable<ILibraryPostScanTask> PostscanTasks { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the prescan tasks.
|
||||
/// </summary>
|
||||
/// <value>The prescan tasks.</value>
|
||||
private IEnumerable<ILibraryPrescanTask> PrescanTasks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the people prescan tasks.
|
||||
/// </summary>
|
||||
/// <value>The people prescan tasks.</value>
|
||||
private IEnumerable<IPeoplePrescanTask> PeoplePrescanTasks { get; set; }
|
||||
private ILibraryPostScanTask[] PostscanTasks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the intro providers.
|
||||
/// </summary>
|
||||
/// <value>The intro providers.</value>
|
||||
private IEnumerable<IIntroProvider> IntroProviders { get; set; }
|
||||
private IIntroProvider[] IntroProviders { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of entity resolution ignore rules
|
||||
@@ -205,26 +194,27 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <param name="resolvers">The resolvers.</param>
|
||||
/// <param name="introProviders">The intro providers.</param>
|
||||
/// <param name="itemComparers">The item comparers.</param>
|
||||
/// <param name="prescanTasks">The prescan tasks.</param>
|
||||
/// <param name="postscanTasks">The postscan tasks.</param>
|
||||
/// <param name="peoplePrescanTasks">The people prescan tasks.</param>
|
||||
public void AddParts(IEnumerable<IResolverIgnoreRule> rules,
|
||||
IEnumerable<IVirtualFolderCreator> pluginFolders,
|
||||
IEnumerable<IItemResolver> resolvers,
|
||||
IEnumerable<IIntroProvider> introProviders,
|
||||
IEnumerable<IBaseItemComparer> itemComparers,
|
||||
IEnumerable<ILibraryPrescanTask> prescanTasks,
|
||||
IEnumerable<ILibraryPostScanTask> postscanTasks,
|
||||
IEnumerable<IPeoplePrescanTask> peoplePrescanTasks)
|
||||
IEnumerable<ILibraryPostScanTask> postscanTasks)
|
||||
{
|
||||
EntityResolutionIgnoreRules = rules.ToArray();
|
||||
PluginFolderCreators = pluginFolders.ToArray();
|
||||
EntityResolvers = resolvers.OrderBy(i => i.Priority).ToArray();
|
||||
IntroProviders = introProviders;
|
||||
IntroProviders = introProviders.ToArray();
|
||||
Comparers = itemComparers.ToArray();
|
||||
PrescanTasks = prescanTasks;
|
||||
PostscanTasks = postscanTasks;
|
||||
PeoplePrescanTasks = peoplePrescanTasks;
|
||||
|
||||
PostscanTasks = postscanTasks.OrderBy(i =>
|
||||
{
|
||||
var hasOrder = i as IHasOrder;
|
||||
|
||||
return hasOrder == null ? 0 : hasOrder.Order;
|
||||
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -845,7 +835,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>Task.</returns>
|
||||
public Task ValidatePeople(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
return new PeopleValidator(this, PeoplePrescanTasks, _logger).ValidatePeople(cancellationToken, progress);
|
||||
return new PeopleValidator(this, _logger).ValidatePeople(cancellationToken, progress);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -970,14 +960,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
innerProgress.RegisterAction(pct => progress.Report(2 + pct * .13));
|
||||
|
||||
// Run prescan tasks
|
||||
await RunPrescanTasks(innerProgress, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
progress.Report(15);
|
||||
|
||||
innerProgress = new ActionableProgress<double>();
|
||||
|
||||
innerProgress.RegisterAction(pct => progress.Report(15 + pct * .6));
|
||||
innerProgress.RegisterAction(pct => progress.Report(2 + pct * .73));
|
||||
|
||||
// Now validate the entire media library
|
||||
await RootFolder.ValidateChildren(innerProgress, cancellationToken, new MetadataRefreshOptions(), recursive: true).ConfigureAwait(false);
|
||||
@@ -998,55 +983,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
GC.Collect(2, GCCollectionMode.Forced, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the prescan tasks.
|
||||
/// </summary>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task RunPrescanTasks(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var tasks = PrescanTasks.ToList();
|
||||
|
||||
var numComplete = 0;
|
||||
var numTasks = tasks.Count;
|
||||
|
||||
foreach (var task in tasks)
|
||||
{
|
||||
var innerProgress = new ActionableProgress<double>();
|
||||
|
||||
// Prevent access to modified closure
|
||||
var currentNumComplete = numComplete;
|
||||
|
||||
innerProgress.RegisterAction(pct =>
|
||||
{
|
||||
double innerPercent = (currentNumComplete * 100) + pct;
|
||||
innerPercent /= numTasks;
|
||||
progress.Report(innerPercent);
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
await task.Run(innerProgress, cancellationToken);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_logger.Info("Pre-scan task cancelled: {0}", task.GetType().Name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error running pre-scan task", ex);
|
||||
}
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= numTasks;
|
||||
progress.Report(percent * 100);
|
||||
}
|
||||
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the post scan tasks.
|
||||
/// </summary>
|
||||
|
||||
@@ -3,7 +3,6 @@ using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MoreLinq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -24,19 +23,15 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IEnumerable<IPeoplePrescanTask> _prescanTasks;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PeopleValidator" /> class.
|
||||
/// </summary>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="prescanTasks">The prescan tasks.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public PeopleValidator(ILibraryManager libraryManager, IEnumerable<IPeoplePrescanTask> prescanTasks, ILogger logger)
|
||||
public PeopleValidator(ILibraryManager libraryManager, ILogger logger)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_logger = logger;
|
||||
_prescanTasks = prescanTasks;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -51,11 +46,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
innerProgress.RegisterAction(pct => progress.Report(pct * .15));
|
||||
|
||||
// Run prescan tasks
|
||||
await RunPrescanTasks(innerProgress, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
progress.Report(15);
|
||||
|
||||
var people = _libraryManager.RootFolder.GetRecursiveChildren()
|
||||
.SelectMany(c => c.People)
|
||||
.DistinctBy(p => p.Name, StringComparer.OrdinalIgnoreCase)
|
||||
@@ -94,55 +84,5 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
GC.Collect(2, GCCollectionMode.Forced, true);
|
||||
GC.Collect(2, GCCollectionMode.Forced, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs the prescan tasks.
|
||||
/// </summary>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task RunPrescanTasks(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var tasks = _prescanTasks.ToList();
|
||||
|
||||
var numComplete = 0;
|
||||
var numTasks = tasks.Count;
|
||||
|
||||
foreach (var task in tasks)
|
||||
{
|
||||
var innerProgress = new ActionableProgress<double>();
|
||||
|
||||
// Prevent access to modified closure
|
||||
var currentNumComplete = numComplete;
|
||||
|
||||
innerProgress.RegisterAction(pct =>
|
||||
{
|
||||
double innerPercent = (currentNumComplete * 100) + pct;
|
||||
innerPercent /= numTasks;
|
||||
progress.Report(innerPercent);
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
await task.Run(innerProgress, cancellationToken);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_logger.Info("Pre-scan task cancelled: {0}", task.GetType().Name);
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error running pre-scan task", ex);
|
||||
}
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= numTasks;
|
||||
progress.Report(percent * 100);
|
||||
}
|
||||
|
||||
progress.Report(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user