mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
Merge pull request #1864 from Bond-009/installationmanager
Improve IInstallationManager interface
This commit is contained in:
commit
0b02c77691
11 changed files with 165 additions and 251 deletions
|
@ -160,7 +160,7 @@ namespace Emby.Dlna.PlayTo
|
||||||
uuid = location.GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
uuid = location.GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersion, uuid, null, uri.OriginalString, null);
|
var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersionString, uuid, null, uri.OriginalString, null);
|
||||||
|
|
||||||
var controller = sessionInfo.SessionControllers.OfType<PlayToController>().FirstOrDefault();
|
var controller = sessionInfo.SessionControllers.OfType<PlayToController>().FirstOrDefault();
|
||||||
|
|
||||||
|
|
|
@ -410,13 +410,17 @@ namespace Emby.Server.Implementations
|
||||||
_validAddressResults.Clear();
|
_validAddressResults.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ApplicationVersion { get; } = typeof(ApplicationHost).Assembly.GetName().Version.ToString(3);
|
/// <inheritdoc />
|
||||||
|
public Version ApplicationVersion { get; } = typeof(ApplicationHost).Assembly.GetName().Version;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string ApplicationVersionString { get; } = typeof(ApplicationHost).Assembly.GetName().Version.ToString(3);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the current application user agent.
|
/// Gets the current application user agent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The application user agent.</value>
|
/// <value>The application user agent.</value>
|
||||||
public string ApplicationUserAgent => Name.Replace(' ', '-') + "/" + ApplicationVersion;
|
public string ApplicationUserAgent => Name.Replace(' ', '-') + "/" + ApplicationVersionString;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the email address for use within a comment section of a user agent field.
|
/// Gets the email address for use within a comment section of a user agent field.
|
||||||
|
@ -1424,7 +1428,7 @@ namespace Emby.Server.Implementations
|
||||||
{
|
{
|
||||||
HasPendingRestart = HasPendingRestart,
|
HasPendingRestart = HasPendingRestart,
|
||||||
IsShuttingDown = IsShuttingDown,
|
IsShuttingDown = IsShuttingDown,
|
||||||
Version = ApplicationVersion,
|
Version = ApplicationVersionString,
|
||||||
WebSocketPortNumber = HttpPort,
|
WebSocketPortNumber = HttpPort,
|
||||||
CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(),
|
CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(),
|
||||||
Id = SystemId,
|
Id = SystemId,
|
||||||
|
@ -1464,7 +1468,7 @@ namespace Emby.Server.Implementations
|
||||||
|
|
||||||
return new PublicSystemInfo
|
return new PublicSystemInfo
|
||||||
{
|
{
|
||||||
Version = ApplicationVersion,
|
Version = ApplicationVersionString,
|
||||||
ProductName = ApplicationProductName,
|
ProductName = ApplicationProductName,
|
||||||
Id = SystemId,
|
Id = SystemId,
|
||||||
OperatingSystem = OperatingSystem.Id.ToString(),
|
OperatingSystem = OperatingSystem.Id.ToString(),
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
using MediaBrowser.Common.Updates;
|
|
||||||
using MediaBrowser.Model.Net;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Progress;
|
using MediaBrowser.Common.Updates;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.Model.Tasks;
|
using MediaBrowser.Model.Tasks;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.ScheduledTasks
|
namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plugin Update Task
|
/// Plugin Update Task.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PluginUpdateTask : IScheduledTask, IConfigurableScheduledTask
|
public class PluginUpdateTask : IScheduledTask, IConfigurableScheduledTask
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _logger
|
/// The _logger.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
@ -31,7 +30,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the triggers that define when the task will run
|
/// Creates the triggers that define when the task will run.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
|
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
|
||||||
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
||||||
|
@ -44,16 +43,16 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update installed plugins
|
/// Update installed plugins.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <param name="progress">The progress.</param>
|
/// <param name="progress">The progress.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns><see cref="Task" />.</returns>
|
||||||
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
|
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
|
||||||
{
|
{
|
||||||
progress.Report(0);
|
progress.Report(0);
|
||||||
|
|
||||||
var packagesToInstall = (await _installationManager.GetAvailablePluginUpdates(typeof(PluginUpdateTask).Assembly.GetName().Version, true, cancellationToken).ConfigureAwait(false)).ToList();
|
var packagesToInstall = (await _installationManager.GetAvailablePluginUpdates(cancellationToken).ConfigureAwait(false)).ToList();
|
||||||
|
|
||||||
progress.Report(10);
|
progress.Report(10);
|
||||||
|
|
||||||
|
@ -94,18 +93,25 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public string Name => "Check for plugin updates";
|
public string Name => "Check for plugin updates";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public string Description => "Downloads and installs updates for plugins that are configured to update automatically.";
|
public string Description => "Downloads and installs updates for plugins that are configured to update automatically.";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public string Category => "Application";
|
public string Category => "Application";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public string Key => "PluginUpdates";
|
public string Key => "PluginUpdates";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public bool IsHidden => false;
|
public bool IsHidden => false;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public bool IsEnabled => true;
|
public bool IsEnabled => true;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public bool IsLogged => true;
|
public bool IsLogged => true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
@ -22,7 +23,7 @@ using Microsoft.Extensions.Logging;
|
||||||
namespace Emby.Server.Implementations.Updates
|
namespace Emby.Server.Implementations.Updates
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Manages all install, uninstall and update operations (both plugins and system)
|
/// Manages all install, uninstall and update operations (both plugins and system).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class InstallationManager : IInstallationManager
|
public class InstallationManager : IInstallationManager
|
||||||
{
|
{
|
||||||
|
@ -49,12 +50,12 @@ namespace Emby.Server.Implementations.Updates
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current installations.
|
/// The current installations.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<(InstallationInfo info, CancellationTokenSource token)> _currentInstallations;
|
private readonly List<(InstallationInfo info, CancellationTokenSource token)> _currentInstallations;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The completed installations.
|
/// The completed installations.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ConcurrentBag<InstallationInfo> _completedInstallationsInternal;
|
private readonly ConcurrentBag<InstallationInfo> _completedInstallationsInternal;
|
||||||
|
|
||||||
public InstallationManager(
|
public InstallationManager(
|
||||||
ILogger<InstallationManager> logger,
|
ILogger<InstallationManager> logger,
|
||||||
|
@ -84,51 +85,32 @@ namespace Emby.Server.Implementations.Updates
|
||||||
_zipClient = zipClient;
|
_zipClient = zipClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public event EventHandler<InstallationEventArgs> PackageInstalling;
|
public event EventHandler<InstallationEventArgs> PackageInstalling;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public event EventHandler<InstallationEventArgs> PackageInstallationCompleted;
|
public event EventHandler<InstallationEventArgs> PackageInstallationCompleted;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed;
|
public event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public event EventHandler<InstallationEventArgs> PackageInstallationCancelled;
|
public event EventHandler<InstallationEventArgs> PackageInstallationCancelled;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Occurs when a plugin is uninstalled.
|
|
||||||
/// </summary>
|
|
||||||
public event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled;
|
public event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Occurs when a plugin plugin is updated.
|
|
||||||
/// </summary>
|
|
||||||
public event EventHandler<GenericEventArgs<(IPlugin, PackageVersionInfo)>> PluginUpdated;
|
public event EventHandler<GenericEventArgs<(IPlugin, PackageVersionInfo)>> PluginUpdated;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Occurs when a plugin plugin is installed.
|
|
||||||
/// </summary>
|
|
||||||
public event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled;
|
public event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public IEnumerable<InstallationInfo> CompletedInstallations => _completedInstallationsInternal;
|
public IEnumerable<InstallationInfo> CompletedInstallations => _completedInstallationsInternal;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets all available packages.
|
public async Task<IReadOnlyList<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken = default)
|
||||||
/// </summary>
|
|
||||||
/// <returns>Task{List{PackageInfo}}.</returns>
|
|
||||||
public async Task<List<PackageInfo>> GetAvailablePackages(
|
|
||||||
CancellationToken cancellationToken,
|
|
||||||
bool withRegistration = true,
|
|
||||||
string packageType = null,
|
|
||||||
Version applicationVersion = null)
|
|
||||||
{
|
|
||||||
var packages = await GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false);
|
|
||||||
return FilterPackages(packages, packageType, applicationVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets all available packages.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
|
||||||
/// <returns>Task{List{PackageInfo}}.</returns>
|
|
||||||
public async Task<List<PackageInfo>> GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken)
|
|
||||||
{
|
{
|
||||||
using (var response = await _httpClient.SendAsync(
|
using (var response = await _httpClient.SendAsync(
|
||||||
new HttpRequestOptions
|
new HttpRequestOptions
|
||||||
|
@ -136,178 +118,91 @@ namespace Emby.Server.Implementations.Updates
|
||||||
Url = "https://repo.jellyfin.org/releases/plugin/manifest.json",
|
Url = "https://repo.jellyfin.org/releases/plugin/manifest.json",
|
||||||
CancellationToken = cancellationToken,
|
CancellationToken = cancellationToken,
|
||||||
CacheMode = CacheMode.Unconditional,
|
CacheMode = CacheMode.Unconditional,
|
||||||
CacheLength = GetCacheLength()
|
CacheLength = TimeSpan.FromMinutes(3)
|
||||||
},
|
},
|
||||||
HttpMethod.Get).ConfigureAwait(false))
|
HttpMethod.Get).ConfigureAwait(false))
|
||||||
using (Stream stream = response.Content)
|
using (Stream stream = response.Content)
|
||||||
{
|
{
|
||||||
return FilterPackages(await _jsonSerializer.DeserializeFromStreamAsync<PackageInfo[]>(stream).ConfigureAwait(false));
|
return await _jsonSerializer.DeserializeFromStreamAsync<IReadOnlyList<PackageInfo>>(
|
||||||
|
stream).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TimeSpan GetCacheLength()
|
/// <inheritdoc />
|
||||||
|
public IEnumerable<PackageInfo> FilterPackages(
|
||||||
|
IEnumerable<PackageInfo> availablePackages,
|
||||||
|
string name = null,
|
||||||
|
Guid guid = default)
|
||||||
{
|
{
|
||||||
return TimeSpan.FromMinutes(3);
|
if (name != null)
|
||||||
|
{
|
||||||
|
availablePackages = availablePackages.Where(x => x.name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<PackageInfo> FilterPackages(IEnumerable<PackageInfo> packages)
|
if (guid != Guid.Empty)
|
||||||
{
|
{
|
||||||
var list = new List<PackageInfo>();
|
var strGuid = guid.ToString("N", CultureInfo.InvariantCulture);
|
||||||
|
availablePackages = availablePackages.Where(x => x.guid.Equals(strGuid, StringComparison.OrdinalIgnoreCase));
|
||||||
foreach (var package in packages)
|
|
||||||
{
|
|
||||||
var versions = new List<PackageVersionInfo>();
|
|
||||||
foreach (var version in package.versions)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(version.sourceUrl))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
versions.Add(version);
|
return availablePackages;
|
||||||
}
|
}
|
||||||
|
|
||||||
package.versions = versions
|
/// <inheritdoc />
|
||||||
.OrderByDescending(x => x.Version)
|
public IEnumerable<PackageVersionInfo> GetCompatibleVersions(
|
||||||
.ToArray();
|
IEnumerable<PackageVersionInfo> availableVersions,
|
||||||
|
Version minVersion = null,
|
||||||
if (package.versions.Length == 0)
|
PackageVersionClass classification = PackageVersionClass.Release)
|
||||||
{
|
{
|
||||||
continue;
|
var appVer = _applicationHost.ApplicationVersion;
|
||||||
}
|
availableVersions = availableVersions
|
||||||
|
.Where(x => x.classification == classification
|
||||||
|
&& Version.Parse(x.requiredVersionStr) <= appVer);
|
||||||
|
|
||||||
list.Add(package);
|
if (minVersion != null)
|
||||||
}
|
|
||||||
|
|
||||||
// Remove packages with no versions
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List<PackageInfo> FilterPackages(IEnumerable<PackageInfo> packages, string packageType, Version applicationVersion)
|
|
||||||
{
|
{
|
||||||
var packagesList = FilterPackages(packages);
|
availableVersions = availableVersions.Where(x => x.Version >= minVersion);
|
||||||
|
|
||||||
var returnList = new List<PackageInfo>();
|
|
||||||
|
|
||||||
var filterOnPackageType = !string.IsNullOrEmpty(packageType);
|
|
||||||
|
|
||||||
foreach (var p in packagesList)
|
|
||||||
{
|
|
||||||
if (filterOnPackageType && !string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If an app version was supplied, filter the versions for each package to only include supported versions
|
return availableVersions.OrderByDescending(x => x.Version);
|
||||||
if (applicationVersion != null)
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public IEnumerable<PackageVersionInfo> GetCompatibleVersions(
|
||||||
|
IEnumerable<PackageInfo> availablePackages,
|
||||||
|
string name = null,
|
||||||
|
Guid guid = default,
|
||||||
|
Version minVersion = null,
|
||||||
|
PackageVersionClass classification = PackageVersionClass.Release)
|
||||||
{
|
{
|
||||||
p.versions = p.versions.Where(v => IsPackageVersionUpToDate(v, applicationVersion)).ToArray();
|
var package = FilterPackages(availablePackages, name, guid).FirstOrDefault();
|
||||||
}
|
|
||||||
|
|
||||||
if (p.versions.Length == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
returnList.Add(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Determines whether [is package version up to date] [the specified package version info].
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="packageVersionInfo">The package version info.</param>
|
|
||||||
/// <param name="currentServerVersion">The current server version.</param>
|
|
||||||
/// <returns><c>true</c> if [is package version up to date] [the specified package version info]; otherwise, <c>false</c>.</returns>
|
|
||||||
private static bool IsPackageVersionUpToDate(PackageVersionInfo packageVersionInfo, Version currentServerVersion)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(packageVersionInfo.requiredVersionStr))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Version.TryParse(packageVersionInfo.requiredVersionStr, out var requiredVersion) && currentServerVersion >= requiredVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the package.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="guid">The assembly guid</param>
|
|
||||||
/// <param name="classification">The classification.</param>
|
|
||||||
/// <param name="version">The version.</param>
|
|
||||||
/// <returns>Task{PackageVersionInfo}.</returns>
|
|
||||||
public async Task<PackageVersionInfo> GetPackage(string name, string guid, PackageVersionClass classification, Version version)
|
|
||||||
{
|
|
||||||
var packages = await GetAvailablePackages(CancellationToken.None, false).ConfigureAwait(false);
|
|
||||||
|
|
||||||
var package = packages.FirstOrDefault(p => string.Equals(p.guid, guid ?? "none", StringComparison.OrdinalIgnoreCase))
|
|
||||||
?? packages.FirstOrDefault(p => p.name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
|
||||||
|
|
||||||
|
// Package not found.
|
||||||
if (package == null)
|
if (package == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return package.versions.FirstOrDefault(v => v.Version == version && v.classification == classification);
|
return GetCompatibleVersions(
|
||||||
|
package.versions,
|
||||||
|
minVersion,
|
||||||
|
classification);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc />
|
||||||
/// Gets the latest compatible version.
|
public async Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(CancellationToken cancellationToken = default)
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="guid">The assembly guid if this is a plug-in</param>
|
|
||||||
/// <param name="currentServerVersion">The current server version.</param>
|
|
||||||
/// <param name="classification">The classification.</param>
|
|
||||||
/// <returns>Task{PackageVersionInfo}.</returns>
|
|
||||||
public async Task<PackageVersionInfo> GetLatestCompatibleVersion(string name, string guid, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release)
|
|
||||||
{
|
{
|
||||||
var packages = await GetAvailablePackages(CancellationToken.None, false).ConfigureAwait(false);
|
var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
return GetLatestCompatibleVersion(packages, name, guid, currentServerVersion, classification);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the latest compatible version.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="availablePackages">The available packages.</param>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="currentServerVersion">The current server version.</param>
|
|
||||||
/// <param name="classification">The classification.</param>
|
|
||||||
/// <returns>PackageVersionInfo.</returns>
|
|
||||||
public PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, string guid, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release)
|
|
||||||
{
|
|
||||||
var package = availablePackages.FirstOrDefault(p => string.Equals(p.guid, guid ?? "none", StringComparison.OrdinalIgnoreCase))
|
|
||||||
?? availablePackages.FirstOrDefault(p => p.name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
|
||||||
|
|
||||||
return package?.versions
|
|
||||||
.OrderByDescending(x => x.Version)
|
|
||||||
.FirstOrDefault(v => v.classification <= classification && IsPackageVersionUpToDate(v, currentServerVersion));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the available plugin updates.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="applicationVersion">The current server version.</param>
|
|
||||||
/// <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>> GetAvailablePluginUpdates(Version applicationVersion, bool withAutoUpdateEnabled, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
var catalog = await GetAvailablePackagesWithoutRegistrationInfo(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(p =>
|
return _applicationHost.Plugins.Select(x =>
|
||||||
{
|
{
|
||||||
var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, p.Id.ToString(), applicationVersion, systemUpdateLevel);
|
var compatibleversions = GetCompatibleVersions(catalog, x.Name, x.Id, x.Version, systemUpdateLevel);
|
||||||
|
return compatibleversions.FirstOrDefault(y => y.Version > x.Version);
|
||||||
return latestPluginInfo != null && latestPluginInfo.Version > p.Version ? latestPluginInfo : null;
|
}).Where(x => x != null)
|
||||||
}).Where(i => i != null)
|
.Where(x => !CompletedInstallations.Any(y => string.Equals(y.AssemblyGuid, x.guid, StringComparison.OrdinalIgnoreCase)));
|
||||||
.Where(p => !string.IsNullOrEmpty(p.sourceUrl) && !CompletedInstallations.Any(i => string.Equals(i.AssemblyGuid, p.guid, StringComparison.OrdinalIgnoreCase)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -393,7 +288,7 @@ namespace Emby.Server.Implementations.Updates
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// Dispose the progress object and remove the installation from the in-progress list
|
// Dispose the progress object and remove the installation from the in-progress list
|
||||||
tuple.Item2.Dispose();
|
tuple.innerCancellationTokenSource.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +336,7 @@ namespace Emby.Server.Implementations.Updates
|
||||||
// Always override the passed-in target (which is a file) and figure it out again
|
// Always override the passed-in target (which is a file) and figure it out again
|
||||||
string targetDir = Path.Combine(_appPaths.PluginsPath, package.name);
|
string targetDir = Path.Combine(_appPaths.PluginsPath, package.name);
|
||||||
|
|
||||||
// CA5351: Do Not Use Broken Cryptographic Algorithms
|
// CA5351: Do Not Use Broken Cryptographic Algorithms
|
||||||
#pragma warning disable CA5351
|
#pragma warning disable CA5351
|
||||||
using (var res = await _httpClient.SendAsync(
|
using (var res = await _httpClient.SendAsync(
|
||||||
new HttpRequestOptions
|
new HttpRequestOptions
|
||||||
|
@ -539,18 +434,19 @@ namespace Emby.Server.Implementations.Updates
|
||||||
{
|
{
|
||||||
lock (_currentInstallationsLock)
|
lock (_currentInstallationsLock)
|
||||||
{
|
{
|
||||||
var install = _currentInstallations.Find(x => x.Item1.Id == id);
|
var install = _currentInstallations.Find(x => x.info.Id == id);
|
||||||
if (install == default((InstallationInfo, CancellationTokenSource)))
|
if (install == default((InstallationInfo, CancellationTokenSource)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
install.Item2.Cancel();
|
install.token.Cancel();
|
||||||
_currentInstallations.Remove(install);
|
_currentInstallations.Remove(install);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@ -569,7 +465,7 @@ namespace Emby.Server.Implementations.Updates
|
||||||
{
|
{
|
||||||
foreach (var tuple in _currentInstallations)
|
foreach (var tuple in _currentInstallations)
|
||||||
{
|
{
|
||||||
tuple.Item2.Dispose();
|
tuple.token.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentInstallations.Clear();
|
_currentInstallations.Clear();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common;
|
using MediaBrowser.Common;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Progress;
|
|
||||||
using MediaBrowser.Common.Updates;
|
using MediaBrowser.Common.Updates;
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Model.Services;
|
using MediaBrowser.Model.Services;
|
||||||
|
@ -133,7 +133,7 @@ namespace MediaBrowser.Api
|
||||||
/// <returns>System.Object.</returns>
|
/// <returns>System.Object.</returns>
|
||||||
public object Get(GetPackage request)
|
public object Get(GetPackage request)
|
||||||
{
|
{
|
||||||
var packages = _installationManager.GetAvailablePackages(CancellationToken.None, applicationVersion: typeof(PackageService).Assembly.GetName().Version).Result;
|
var packages = _installationManager.GetAvailablePackages().Result;
|
||||||
|
|
||||||
var result = packages.FirstOrDefault(p => string.Equals(p.guid, request.AssemblyGuid ?? "none", StringComparison.OrdinalIgnoreCase))
|
var result = packages.FirstOrDefault(p => string.Equals(p.guid, request.AssemblyGuid ?? "none", StringComparison.OrdinalIgnoreCase))
|
||||||
?? packages.FirstOrDefault(p => p.name.Equals(request.Name, StringComparison.OrdinalIgnoreCase));
|
?? packages.FirstOrDefault(p => p.name.Equals(request.Name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
@ -148,7 +148,7 @@ namespace MediaBrowser.Api
|
||||||
/// <returns>System.Object.</returns>
|
/// <returns>System.Object.</returns>
|
||||||
public async Task<object> Get(GetPackages request)
|
public async Task<object> Get(GetPackages request)
|
||||||
{
|
{
|
||||||
IEnumerable<PackageInfo> packages = await _installationManager.GetAvailablePackages(CancellationToken.None, false, request.PackageType, typeof(PackageService).Assembly.GetName().Version).ConfigureAwait(false);
|
IEnumerable<PackageInfo> packages = await _installationManager.GetAvailablePackages().ConfigureAwait(false);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(request.TargetSystems))
|
if (!string.IsNullOrEmpty(request.TargetSystems))
|
||||||
{
|
{
|
||||||
|
@ -157,11 +157,6 @@ namespace MediaBrowser.Api
|
||||||
packages = packages.Where(p => apps.Contains(p.targetSystem));
|
packages = packages.Where(p => apps.Contains(p.targetSystem));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.IsPremium.HasValue)
|
|
||||||
{
|
|
||||||
packages = packages.Where(p => p.isPremium == request.IsPremium.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.IsAdult.HasValue)
|
if (request.IsAdult.HasValue)
|
||||||
{
|
{
|
||||||
packages = packages.Where(p => p.adult == request.IsAdult.Value);
|
packages = packages.Where(p => p.adult == request.IsAdult.Value);
|
||||||
|
@ -182,13 +177,21 @@ namespace MediaBrowser.Api
|
||||||
/// <exception cref="ResourceNotFoundException"></exception>
|
/// <exception cref="ResourceNotFoundException"></exception>
|
||||||
public async Task Post(InstallPackage request)
|
public async Task Post(InstallPackage request)
|
||||||
{
|
{
|
||||||
var package = string.IsNullOrEmpty(request.Version) ?
|
var packages = await _installationManager.GetAvailablePackages().ConfigureAwait(false);
|
||||||
await _installationManager.GetLatestCompatibleVersion(request.Name, request.AssemblyGuid, typeof(PackageService).Assembly.GetName().Version, request.UpdateClass).ConfigureAwait(false) :
|
var package = _installationManager.GetCompatibleVersions(
|
||||||
await _installationManager.GetPackage(request.Name, request.AssemblyGuid, request.UpdateClass, Version.Parse(request.Version)).ConfigureAwait(false);
|
packages,
|
||||||
|
request.Name,
|
||||||
|
new Guid(request.AssemblyGuid),
|
||||||
|
string.IsNullOrEmpty(request.Version) ? null : Version.Parse(request.Version),
|
||||||
|
request.UpdateClass).FirstOrDefault();
|
||||||
|
|
||||||
if (package == null)
|
if (package == null)
|
||||||
{
|
{
|
||||||
throw new ResourceNotFoundException(string.Format("Package not found: {0}", request.Name));
|
throw new ResourceNotFoundException(
|
||||||
|
string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
"Package not found: {0}",
|
||||||
|
request.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
await _installationManager.InstallPackage(package);
|
await _installationManager.InstallPackage(package);
|
||||||
|
|
|
@ -321,7 +321,7 @@ namespace MediaBrowser.Api.Session
|
||||||
DateCreated = DateTime.UtcNow,
|
DateCreated = DateTime.UtcNow,
|
||||||
DeviceId = _appHost.SystemId,
|
DeviceId = _appHost.SystemId,
|
||||||
DeviceName = _appHost.FriendlyName,
|
DeviceName = _appHost.FriendlyName,
|
||||||
AppVersion = _appHost.ApplicationVersion
|
AppVersion = _appHost.ApplicationVersionString
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,13 @@ namespace MediaBrowser.Common
|
||||||
/// Gets the application version.
|
/// Gets the application version.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The application version.</value>
|
/// <value>The application version.</value>
|
||||||
string ApplicationVersion { get; }
|
Version ApplicationVersion { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the application version.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The application version.</value>
|
||||||
|
string ApplicationVersionString { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the application user agent.
|
/// Gets the application user agent.
|
||||||
|
|
|
@ -13,87 +13,86 @@ namespace MediaBrowser.Common.Updates
|
||||||
public interface IInstallationManager : IDisposable
|
public interface IInstallationManager : IDisposable
|
||||||
{
|
{
|
||||||
event EventHandler<InstallationEventArgs> PackageInstalling;
|
event EventHandler<InstallationEventArgs> PackageInstalling;
|
||||||
|
|
||||||
event EventHandler<InstallationEventArgs> PackageInstallationCompleted;
|
event EventHandler<InstallationEventArgs> PackageInstallationCompleted;
|
||||||
|
|
||||||
event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed;
|
event EventHandler<InstallationFailedEventArgs> PackageInstallationFailed;
|
||||||
|
|
||||||
event EventHandler<InstallationEventArgs> PackageInstallationCancelled;
|
event EventHandler<InstallationEventArgs> PackageInstallationCancelled;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The completed installations
|
/// Occurs when a plugin is uninstalled.
|
||||||
/// </summary>
|
|
||||||
IEnumerable<InstallationInfo> CompletedInstallations { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Occurs when [plugin uninstalled].
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled;
|
event EventHandler<GenericEventArgs<IPlugin>> PluginUninstalled;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when [plugin updated].
|
/// Occurs when a plugin is updated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event EventHandler<GenericEventArgs<(IPlugin, PackageVersionInfo)>> PluginUpdated;
|
event EventHandler<GenericEventArgs<(IPlugin, PackageVersionInfo)>> PluginUpdated;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when [plugin updated].
|
/// Occurs when a plugin is installed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled;
|
event EventHandler<GenericEventArgs<PackageVersionInfo>> PluginInstalled;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the completed installations.
|
||||||
|
/// </summary>
|
||||||
|
IEnumerable<InstallationInfo> CompletedInstallations { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all available packages.
|
/// Gets all available packages.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <param name="withRegistration">if set to <c>true</c> [with registration].</param>
|
/// <returns>Task{IReadOnlyList{PackageInfo}}.</returns>
|
||||||
/// <param name="packageType">Type of the package.</param>
|
Task<IReadOnlyList<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken = default);
|
||||||
/// <param name="applicationVersion">The application version.</param>
|
|
||||||
/// <returns>Task{List{PackageInfo}}.</returns>
|
|
||||||
Task<List<PackageInfo>> GetAvailablePackages(CancellationToken cancellationToken,
|
|
||||||
bool withRegistration = true, string packageType = null, Version applicationVersion = null);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all available packages from a static resource.
|
/// Returns all plugins matching the requirements.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="availablePackages">The available packages.</param>
|
||||||
/// <returns>Task{List{PackageInfo}}.</returns>
|
/// <param name="name">The name of the plugin.</param>
|
||||||
Task<List<PackageInfo>> GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken);
|
/// <param name="guid">The id of the plugin.</param>
|
||||||
|
/// <returns>All plugins matching the requirements.</returns>
|
||||||
|
IEnumerable<PackageInfo> FilterPackages(
|
||||||
|
IEnumerable<PackageInfo> availablePackages,
|
||||||
|
string name = null,
|
||||||
|
Guid guid = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the package.
|
/// Returns all compatible versions ordered from newest to oldest.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="availableVersions">The available version of the plugin.</param>
|
||||||
/// <param name="guid">The assembly guid</param>
|
/// <param name="minVersion">The minimum required version of the plugin.</param>
|
||||||
/// <param name="classification">The classification.</param>
|
/// <param name="classification">The classification of updates.</param>
|
||||||
/// <param name="version">The version.</param>
|
/// <returns>All compatible versions ordered from newest to oldest.</returns>
|
||||||
/// <returns>Task{PackageVersionInfo}.</returns>
|
IEnumerable<PackageVersionInfo> GetCompatibleVersions(
|
||||||
Task<PackageVersionInfo> GetPackage(string name, string guid, PackageVersionClass classification, Version version);
|
IEnumerable<PackageVersionInfo> availableVersions,
|
||||||
|
Version minVersion = null,
|
||||||
|
PackageVersionClass classification = PackageVersionClass.Release);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the latest compatible version.
|
/// Returns all compatible versions ordered from newest to oldest.
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="guid">The assembly guid</param>
|
|
||||||
/// <param name="currentServerVersion">The current server version.</param>
|
|
||||||
/// <param name="classification">The classification.</param>
|
|
||||||
/// <returns>Task{PackageVersionInfo}.</returns>
|
|
||||||
Task<PackageVersionInfo> GetLatestCompatibleVersion(string name, string guid, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the latest compatible version.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="availablePackages">The available packages.</param>
|
/// <param name="availablePackages">The available packages.</param>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="guid">The assembly guid</param>
|
/// <param name="guid">The guid of the plugin.</param>
|
||||||
/// <param name="currentServerVersion">The current server version.</param>
|
/// <param name="minVersion">The minimum required version of the plugin.</param>
|
||||||
/// <param name="classification">The classification.</param>
|
/// <param name="classification">The classification.</param>
|
||||||
/// <returns>PackageVersionInfo.</returns>
|
/// <returns>All compatible versions ordered from newest to oldest.</returns>
|
||||||
PackageVersionInfo GetLatestCompatibleVersion(IEnumerable<PackageInfo> availablePackages, string name, string guid, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release);
|
IEnumerable<PackageVersionInfo> GetCompatibleVersions(
|
||||||
|
IEnumerable<PackageInfo> availablePackages,
|
||||||
|
string name = null,
|
||||||
|
Guid guid = default,
|
||||||
|
Version minVersion = null,
|
||||||
|
PackageVersionClass classification = PackageVersionClass.Release);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the available plugin updates.
|
/// Returns the available plugin updates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="applicationVersion">The current server version.</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>The available plugin updates.</returns>
|
||||||
Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(Version applicationVersion, bool withAutoUpdateEnabled, CancellationToken cancellationToken);
|
Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Installs the package.
|
/// Installs the package.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Updates
|
namespace MediaBrowser.Model.Updates
|
||||||
{
|
{
|
||||||
|
@ -150,7 +151,7 @@ namespace MediaBrowser.Model.Updates
|
||||||
/// Gets or sets the versions.
|
/// Gets or sets the versions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The versions.</value>
|
/// <value>The versions.</value>
|
||||||
public PackageVersionInfo[] versions { get; set; }
|
public IReadOnlyList<PackageVersionInfo> versions { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether [enable in application store].
|
/// Gets or sets a value indicating whether [enable in application store].
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
namespace MediaBrowser.Providers.TV.TheTVDB
|
namespace MediaBrowser.Providers.TV.TheTVDB
|
||||||
{
|
{
|
||||||
|
|
|
@ -205,7 +205,7 @@ namespace MediaBrowser.WebDashboard.Api
|
||||||
return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => Task.FromResult(stream));
|
return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => Task.FromResult(stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator(DashboardUIPath).ModifyHtml("dummy.html", stream, null, _appHost.ApplicationVersion, null));
|
return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator(DashboardUIPath).ModifyHtml("dummy.html", stream, null, _appHost.ApplicationVersionString, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException();
|
||||||
|
@ -342,7 +342,7 @@ namespace MediaBrowser.WebDashboard.Api
|
||||||
cacheDuration = TimeSpan.FromDays(365);
|
cacheDuration = TimeSpan.FromDays(365);
|
||||||
}
|
}
|
||||||
|
|
||||||
var cacheKey = (_appHost.ApplicationVersion + (localizationCulture ?? string.Empty) + path).GetMD5();
|
var cacheKey = (_appHost.ApplicationVersionString + (localizationCulture ?? string.Empty) + path).GetMD5();
|
||||||
|
|
||||||
// html gets modified on the fly
|
// html gets modified on the fly
|
||||||
if (contentType.StartsWith("text/html", StringComparison.OrdinalIgnoreCase))
|
if (contentType.StartsWith("text/html", StringComparison.OrdinalIgnoreCase))
|
||||||
|
@ -364,7 +364,7 @@ namespace MediaBrowser.WebDashboard.Api
|
||||||
private Task<Stream> GetResourceStream(string basePath, string virtualPath, string localizationCulture)
|
private Task<Stream> GetResourceStream(string basePath, string virtualPath, string localizationCulture)
|
||||||
{
|
{
|
||||||
return GetPackageCreator(basePath)
|
return GetPackageCreator(basePath)
|
||||||
.GetResource(virtualPath, null, localizationCulture, _appHost.ApplicationVersion);
|
.GetResource(virtualPath, null, localizationCulture, _appHost.ApplicationVersionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PackageCreator GetPackageCreator(string basePath)
|
private PackageCreator GetPackageCreator(string basePath)
|
||||||
|
@ -400,7 +400,7 @@ namespace MediaBrowser.WebDashboard.Api
|
||||||
CopyDirectory(inputPath, targetPath);
|
CopyDirectory(inputPath, targetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
var appVersion = _appHost.ApplicationVersion;
|
var appVersion = _appHost.ApplicationVersionString;
|
||||||
|
|
||||||
await DumpHtml(packageCreator, inputPath, targetPath, mode, appVersion);
|
await DumpHtml(packageCreator, inputPath, targetPath, mode, appVersion);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue