aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Updates/InstallationManager.cs
diff options
context:
space:
mode:
authorDominik <git@secnd.me>2023-06-15 19:38:42 +0200
committerGitHub <noreply@github.com>2023-06-15 19:38:42 +0200
commit17f1e8d19b1fd693893d66d2275ed8ae2476344e (patch)
tree7f48be975faa92042769870957587b3c7864f631 /Emby.Server.Implementations/Updates/InstallationManager.cs
parente8ae7e5c38e28f13fa8de295e26c930cb46d9b79 (diff)
parent6771b5cabe96b4b3cbd1cd0c998d564f3dd17ed4 (diff)
Merge branch 'master' into segment-deletion
Diffstat (limited to 'Emby.Server.Implementations/Updates/InstallationManager.cs')
-rw-r--r--Emby.Server.Implementations/Updates/InstallationManager.cs33
1 files changed, 18 insertions, 15 deletions
diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs
index 550f0e075..6c198b6f9 100644
--- a/Emby.Server.Implementations/Updates/InstallationManager.cs
+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs
@@ -102,7 +102,7 @@ namespace Emby.Server.Implementations.Updates
PackageInfo[]? packages = await _httpClientFactory.CreateClient(NamedClient.Default)
.GetFromJsonAsync<PackageInfo[]>(new Uri(manifest), _jsonSerializerOptions, cancellationToken).ConfigureAwait(false);
- if (packages == null)
+ if (packages is null)
{
return Array.Empty<PackageInfo>();
}
@@ -168,7 +168,7 @@ namespace Emby.Server.Implementations.Updates
var result = new List<PackageInfo>();
foreach (RepositoryInfo repository in _config.Configuration.PluginRepositories)
{
- if (repository.Enabled && repository.Url != null)
+ if (repository.Enabled && repository.Url is not null)
{
// Where repositories have the same content, the details from the first is taken.
foreach (var package in await GetPackages(repository.Name ?? "Unnamed Repo", repository.Url, true, cancellationToken).ConfigureAwait(true))
@@ -181,9 +181,9 @@ namespace Emby.Server.Implementations.Updates
var version = package.Versions[i];
var plugin = _pluginManager.GetPlugin(package.Id, version.VersionNumber);
- if (plugin != null)
+ if (plugin is not null)
{
- await _pluginManager.GenerateManifest(package, version.VersionNumber, plugin.Path, plugin.Manifest.Status).ConfigureAwait(false);
+ await _pluginManager.PopulateManifest(package, version.VersionNumber, plugin.Path, plugin.Manifest.Status).ConfigureAwait(false);
}
// Remove versions with a target ABI greater then the current application version.
@@ -199,7 +199,7 @@ namespace Emby.Server.Implementations.Updates
continue;
}
- if (existing != null)
+ if (existing is not null)
{
// Assumption is both lists are ordered, so slot these into the correct place.
MergeSortedList(existing.Versions, package.Versions);
@@ -222,7 +222,7 @@ namespace Emby.Server.Implementations.Updates
Guid id = default,
Version? specificVersion = null)
{
- if (name != null)
+ if (name is not null)
{
availablePackages = availablePackages.Where(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
}
@@ -232,7 +232,7 @@ namespace Emby.Server.Implementations.Updates
availablePackages = availablePackages.Where(x => x.Id.Equals(id));
}
- if (specificVersion != null)
+ if (specificVersion is not null)
{
availablePackages = availablePackages.Where(x => x.Versions.Any(y => y.VersionNumber.Equals(specificVersion)));
}
@@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.Updates
var package = FilterPackages(availablePackages, name, id, specificVersion).FirstOrDefault();
// Package not found in repository
- if (package == null)
+ if (package is null)
{
yield break;
}
@@ -260,11 +260,11 @@ namespace Emby.Server.Implementations.Updates
var availableVersions = package.Versions
.Where(x => string.IsNullOrEmpty(x.TargetAbi) || Version.Parse(x.TargetAbi) <= appVer);
- if (specificVersion != null)
+ if (specificVersion is not null)
{
availableVersions = availableVersions.Where(x => x.VersionNumber.Equals(specificVersion));
}
- else if (minVersion != null)
+ else if (minVersion is not null)
{
availableVersions = availableVersions.Where(x => x.VersionNumber >= minVersion);
}
@@ -370,7 +370,7 @@ namespace Emby.Server.Implementations.Updates
/// <param name="plugin">The <see cref="LocalPlugin"/> to uninstall.</param>
public void UninstallPlugin(LocalPlugin plugin)
{
- if (plugin == null)
+ if (plugin is null)
{
return;
}
@@ -495,7 +495,7 @@ namespace Emby.Server.Implementations.Updates
var compatibleVersions = GetCompatibleVersions(pluginCatalog, plugin.Name, plugin.Id, minVersion: plugin.Version);
var version = compatibleVersions.FirstOrDefault(y => y.Version > plugin.Version);
- if (version != null && CompletedInstallations.All(x => !x.Id.Equals(version.Id)))
+ if (version is not null && CompletedInstallations.All(x => !x.Id.Equals(version.Id)))
{
yield return version;
}
@@ -555,7 +555,10 @@ namespace Emby.Server.Implementations.Updates
stream.Position = 0;
using var reader = new ZipArchive(stream);
reader.ExtractToDirectory(targetDir, true);
- await _pluginManager.GenerateManifest(package.PackageInfo, package.Version, targetDir, status).ConfigureAwait(false);
+
+ // Ensure we create one or populate existing ones with missing data.
+ await _pluginManager.PopulateManifest(package.PackageInfo, package.Version, targetDir, status);
+
_pluginManager.ImportPluginFrom(targetDir);
}
@@ -565,9 +568,9 @@ namespace Emby.Server.Implementations.Updates
?? _pluginManager.Plugins.FirstOrDefault(p => p.Name.Equals(package.Name, StringComparison.OrdinalIgnoreCase) && p.Version.Equals(package.Version));
await PerformPackageInstallation(package, plugin?.Manifest.Status ?? PluginStatus.Active, cancellationToken).ConfigureAwait(false);
- _logger.LogInformation("Plugin {Action}: {PluginName} {PluginVersion}", plugin == null ? "installed" : "updated", package.Name, package.Version);
+ _logger.LogInformation("Plugin {Action}: {PluginName} {PluginVersion}", plugin is null ? "installed" : "updated", package.Name, package.Version);
- return plugin != null;
+ return plugin is not null;
}
}
}