mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Change update checks to use static file
This commit is contained in:
parent
30eafa61a5
commit
55bbfc2dcc
@ -43,6 +43,12 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get all available packages including registration information.
|
||||||
|
/// Use this for the plug-in catalog to provide all information for this installation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public async Task<IEnumerable<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken)
|
public async Task<IEnumerable<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var data = new Dictionary<string, string> { { "key", _securityManager.SupporterKey }, { "mac", _networkManager.GetMacAddress() } };
|
var data = new Dictionary<string, string> { { "key", _securityManager.SupporterKey }, { "mac", _networkManager.GetMacAddress() } };
|
||||||
@ -52,15 +58,39 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
var packages = _jsonSerializer.DeserializeFromStream<List<PackageInfo>>(json).ToList();
|
var packages = _jsonSerializer.DeserializeFromStream<List<PackageInfo>>(json).ToList();
|
||||||
foreach (var package in packages)
|
|
||||||
|
return FilterVersions(packages);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get all available packages using the static file resource.
|
||||||
|
/// Use this for update checks as it will be much less taxing on the server and can be cached.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<IEnumerable<PackageInfo>> GetAvailablePackagesStatic(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
using (var json = await _httpClient.Get(Constants.Constants.MbAdminUrl + "service/MB3Packages.json", cancellationToken).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
var packages = _jsonSerializer.DeserializeFromStream<List<PackageInfo>>(json).ToList();
|
||||||
|
|
||||||
|
return FilterVersions(packages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<PackageInfo> FilterVersions(List<PackageInfo> original)
|
||||||
|
{
|
||||||
|
foreach (var package in original)
|
||||||
{
|
{
|
||||||
package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl))
|
package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl))
|
||||||
.OrderByDescending(v => v.version).ToList();
|
.OrderByDescending(v => v.version).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return packages;
|
return original;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task InstallPackage(IProgress<double> progress, PackageVersionInfo package, CancellationToken cancellationToken)
|
public async Task InstallPackage(IProgress<double> progress, PackageVersionInfo package, CancellationToken cancellationToken)
|
||||||
|
@ -9,12 +9,19 @@ namespace MediaBrowser.Common.Updates
|
|||||||
public interface IPackageManager
|
public interface IPackageManager
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all available packages.
|
/// Gets all available packages dynamically.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{List{PackageInfo}}.</returns>
|
/// <returns>Task{List{PackageInfo}}.</returns>
|
||||||
Task<IEnumerable<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken);
|
Task<IEnumerable<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all available packages from a static resource.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task{List{PackageInfo}}.</returns>
|
||||||
|
Task<IEnumerable<PackageInfo>> GetAvailablePackagesStatic(CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Installs a package.
|
/// Installs a package.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -79,13 +79,21 @@ namespace MediaBrowser.Controller.Updates
|
|||||||
PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, PackageVersionClass classification = PackageVersionClass.Release);
|
PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, PackageVersionClass classification = PackageVersionClass.Release);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the available plugin updates.
|
/// Gets the available plugin updates including registration info.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param>
|
/// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns>
|
/// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns>
|
||||||
Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken);
|
Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the available plugin updates from a static resource (not including registration info).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns>
|
||||||
|
Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdatesStatic(bool withAutoUpdateEnabled, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Installs the package.
|
/// Installs the package.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -60,7 +60,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
|
|||||||
{
|
{
|
||||||
progress.Report(0);
|
progress.Report(0);
|
||||||
|
|
||||||
var packagesToInstall = (await _installationManager.GetAvailablePluginUpdates(true, cancellationToken).ConfigureAwait(false)).ToList();
|
var packagesToInstall = (await _installationManager.GetAvailablePluginUpdatesStatic(true, cancellationToken).ConfigureAwait(false)).ToList();
|
||||||
|
|
||||||
progress.Report(10);
|
progress.Report(10);
|
||||||
|
|
||||||
|
@ -171,6 +171,26 @@ namespace MediaBrowser.Server.Implementations.Updates
|
|||||||
{
|
{
|
||||||
var packages = (await _packageManager.GetAvailablePackages(cancellationToken).ConfigureAwait(false)).ToList();
|
var packages = (await _packageManager.GetAvailablePackages(cancellationToken).ConfigureAwait(false)).ToList();
|
||||||
|
|
||||||
|
return FilterPackages(packages, packageType, applicationVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all available packages.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <param name="packageType">Type of the package.</param>
|
||||||
|
/// <param name="applicationVersion">The application version.</param>
|
||||||
|
/// <returns>Task{List{PackageInfo}}.</returns>
|
||||||
|
protected async Task<IEnumerable<PackageInfo>> GetAvailablePackagesStatic(CancellationToken cancellationToken,
|
||||||
|
PackageType? packageType = null,
|
||||||
|
Version applicationVersion = null)
|
||||||
|
{
|
||||||
|
var packages = (await _packageManager.GetAvailablePackagesStatic(cancellationToken).ConfigureAwait(false)).ToList();
|
||||||
|
return FilterPackages(packages, packageType, applicationVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IEnumerable<PackageInfo> FilterPackages(List<PackageInfo> packages, PackageType? packageType, Version applicationVersion)
|
||||||
|
{
|
||||||
if (packageType.HasValue)
|
if (packageType.HasValue)
|
||||||
{
|
{
|
||||||
packages = packages.Where(p => p.type == packageType.Value).ToList();
|
packages = packages.Where(p => p.type == packageType.Value).ToList();
|
||||||
@ -265,7 +285,8 @@ namespace MediaBrowser.Server.Implementations.Updates
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the available plugin updates.
|
/// Gets the available plugin updates including registration information for each one.
|
||||||
|
/// Used with API and catalog.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param>
|
/// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
@ -273,6 +294,24 @@ namespace MediaBrowser.Server.Implementations.Updates
|
|||||||
public async Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken)
|
public async Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false);
|
var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false);
|
||||||
|
return FilterCatalog(catalog, withAutoUpdateEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the available plugin updates from a static resource - no registration information.
|
||||||
|
/// Used for update checks.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns>
|
||||||
|
public async Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdatesStatic(bool withAutoUpdateEnabled, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var catalog = await GetAvailablePackagesStatic(cancellationToken).ConfigureAwait(false);
|
||||||
|
return FilterCatalog(catalog, withAutoUpdateEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IEnumerable<PackageVersionInfo> FilterCatalog(IEnumerable<PackageInfo> catalog, bool withAutoUpdateEnabled)
|
||||||
|
{
|
||||||
|
|
||||||
var plugins = ApplicationHost.Plugins;
|
var plugins = ApplicationHost.Plugins;
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
/// <returns>Task{CheckForUpdateResult}.</returns>
|
/// <returns>Task{CheckForUpdateResult}.</returns>
|
||||||
public async override Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
|
public async override Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
|
||||||
{
|
{
|
||||||
var availablePackages = await PackageManager.GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
|
var availablePackages = await PackageManager.GetAvailablePackagesStatic(CancellationToken.None).ConfigureAwait(false);
|
||||||
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
||||||
|
|
||||||
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
|
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
|
||||||
|
@ -221,7 +221,4 @@ Global
|
|||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(Performance) = preSolution
|
|
||||||
HasPerformanceSessions = true
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user