Merge pull request #2050 from Bond-009/nullref
Fix possible nullref when updating packages
This commit is contained in:
commit
a7ef1aa7ec
|
@ -37,6 +37,7 @@
|
||||||
<PackageReference Include="ServiceStack.Text.Core" Version="5.7.0" />
|
<PackageReference Include="ServiceStack.Text.Core" Version="5.7.0" />
|
||||||
<PackageReference Include="sharpcompress" Version="0.24.0" />
|
<PackageReference Include="sharpcompress" Version="0.24.0" />
|
||||||
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="2.0.1" />
|
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="2.0.1" />
|
||||||
|
<PackageReference Include="System.Interactive.Async" Version="4.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -52,7 +52,9 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
{
|
{
|
||||||
progress.Report(0);
|
progress.Report(0);
|
||||||
|
|
||||||
var packagesToInstall = (await _installationManager.GetAvailablePluginUpdates(cancellationToken).ConfigureAwait(false)).ToList();
|
var packagesToInstall = await _installationManager.GetAvailablePluginUpdates(cancellationToken)
|
||||||
|
.ToListAsync(cancellationToken)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
progress.Report(10);
|
progress.Report(10);
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ namespace Emby.Server.Implementations.Updates
|
||||||
// Package not found.
|
// Package not found.
|
||||||
if (package == null)
|
if (package == null)
|
||||||
{
|
{
|
||||||
return null;
|
return Enumerable.Empty<PackageVersionInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetCompatibleVersions(
|
return GetCompatibleVersions(
|
||||||
|
@ -190,19 +190,23 @@ namespace Emby.Server.Implementations.Updates
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(CancellationToken cancellationToken = default)
|
public async IAsyncEnumerable<PackageVersionInfo> GetAvailablePluginUpdates(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false);
|
var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var systemUpdateLevel = _applicationHost.SystemUpdateLevel;
|
var systemUpdateLevel = _applicationHost.SystemUpdateLevel;
|
||||||
|
|
||||||
// Figure out what needs to be installed
|
// Figure out what needs to be installed
|
||||||
return _applicationHost.Plugins.Select(x =>
|
foreach (var plugin in _applicationHost.Plugins)
|
||||||
{
|
{
|
||||||
var compatibleversions = GetCompatibleVersions(catalog, x.Name, x.Id, x.Version, systemUpdateLevel);
|
var compatibleversions = GetCompatibleVersions(catalog, plugin.Name, plugin.Id, plugin.Version, systemUpdateLevel);
|
||||||
return compatibleversions.FirstOrDefault(y => y.Version > x.Version);
|
var version = compatibleversions.FirstOrDefault(y => y.Version > plugin.Version);
|
||||||
}).Where(x => x != null)
|
if (version != null
|
||||||
.Where(x => !CompletedInstallations.Any(y => string.Equals(y.AssemblyGuid, x.guid, StringComparison.OrdinalIgnoreCase)));
|
&& !CompletedInstallations.Any(x => string.Equals(x.AssemblyGuid, version.guid, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
yield return version;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace MediaBrowser.Common.Updates
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>The available plugin updates.</returns>
|
/// <returns>The available plugin updates.</returns>
|
||||||
Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(CancellationToken cancellationToken = default);
|
IAsyncEnumerable<PackageVersionInfo> GetAvailablePluginUpdates(CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Installs the package.
|
/// Installs the package.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user