Do not use IAsyncEnumerable unnecessarily

This commit is contained in:
Mark Monteiro 2020-04-06 22:04:24 -04:00
parent 0cd7cd611e
commit 8e3b09a996
3 changed files with 9 additions and 9 deletions

View File

@ -55,9 +55,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
progress.Report(0);
var packagesToInstall = await _installationManager.GetAvailablePluginUpdates(cancellationToken)
.ToListAsync(cancellationToken)
.ConfigureAwait(false);
var packageFetchTask = _installationManager.GetAvailablePluginUpdates(cancellationToken);
var packagesToInstall = (await packageFetchTask.ConfigureAwait(false)).ToList();
progress.Report(10);

View File

@ -189,16 +189,17 @@ namespace Emby.Server.Implementations.Updates
}
/// <inheritdoc />
public async IAsyncEnumerable<PackageVersionInfo> GetAvailablePluginUpdates([EnumeratorCancellation] CancellationToken cancellationToken = default)
public async Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(CancellationToken cancellationToken = default)
{
var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false);
return GetAvailablePluginUpdates(catalog);
}
var systemUpdateLevel = _applicationHost.SystemUpdateLevel;
// Figure out what needs to be installed
private IEnumerable<PackageVersionInfo> GetAvailablePluginUpdates(IReadOnlyList<PackageInfo> pluginCatalog)
{
foreach (var plugin in _applicationHost.Plugins)
{
var compatibleversions = GetCompatibleVersions(catalog, plugin.Name, plugin.Id, plugin.Version, systemUpdateLevel);
var compatibleversions = GetCompatibleVersions(pluginCatalog, plugin.Name, plugin.Id, plugin.Version, _applicationHost.SystemUpdateLevel);
var version = compatibleversions.FirstOrDefault(y => y.Version > plugin.Version);
if (version != null
&& !CompletedInstallations.Any(x => string.Equals(x.AssemblyGuid, version.guid, StringComparison.OrdinalIgnoreCase)))

View File

@ -92,7 +92,7 @@ namespace MediaBrowser.Common.Updates
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The available plugin updates.</returns>
IAsyncEnumerable<PackageVersionInfo> GetAvailablePluginUpdates(CancellationToken cancellationToken = default);
Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(CancellationToken cancellationToken = default);
/// <summary>
/// Installs the package.