Renamed Guid property to Id

This commit is contained in:
Greenback 2020-12-18 20:37:35 +00:00
parent 486148dd6b
commit ce19f2be55
11 changed files with 65 additions and 34 deletions

View File

@ -376,7 +376,7 @@ namespace Emby.Server.Implementations.Plugins
true, true,
new PluginManifest new PluginManifest
{ {
Guid = instance.Id, Id = instance.Id,
Status = PluginStatus.Active, Status = PluginStatus.Active,
Name = instance.Name, Name = instance.Name,
Version = instance.Version.ToString() Version = instance.Version.ToString()
@ -537,7 +537,7 @@ namespace Emby.Server.Implementations.Plugins
Status = PluginStatus.Restart, Status = PluginStatus.Restart,
Name = metafile, Name = metafile,
AutoUpdate = false, AutoUpdate = false,
Guid = metafile.GetMD5(), Id = metafile.GetMD5(),
TargetAbi = _appVersion.ToString(), TargetAbi = _appVersion.ToString(),
Version = version.ToString() Version = version.ToString()
}; };

View File

@ -178,7 +178,7 @@ namespace Emby.Server.Implementations.Updates
// Where repositories have the same content, the details from the first is taken. // 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)) foreach (var package in await GetPackages(repository.Name ?? "Unnamed Repo", repository.Url, true, cancellationToken).ConfigureAwait(true))
{ {
if (!Guid.TryParse(package.Guid, out var packageGuid)) if (!Guid.TryParse(package.Id, out var packageGuid))
{ {
// Package doesn't have a valid GUID, skip. // Package doesn't have a valid GUID, skip.
continue; continue;
@ -245,7 +245,7 @@ namespace Emby.Server.Implementations.Updates
if (guid != Guid.Empty) if (guid != Guid.Empty)
{ {
availablePackages = availablePackages.Where(x => Guid.Parse(x.Guid) == guid); availablePackages = availablePackages.Where(x => Guid.Parse(x.Id) == guid);
} }
if (specificVersion != null) if (specificVersion != null)
@ -290,7 +290,7 @@ namespace Emby.Server.Implementations.Updates
yield return new InstallationInfo yield return new InstallationInfo
{ {
Changelog = v.Changelog, Changelog = v.Changelog,
Guid = new Guid(package.Guid), Id = new Guid(package.Id),
Name = package.Name, Name = package.Name,
Version = v.VersionNumber, Version = v.VersionNumber,
SourceUrl = v.SourceUrl, SourceUrl = v.SourceUrl,
@ -414,7 +414,7 @@ namespace Emby.Server.Implementations.Updates
{ {
lock (_currentInstallationsLock) lock (_currentInstallationsLock)
{ {
var install = _currentInstallations.Find(x => x.info.Guid == id); var install = _currentInstallations.Find(x => x.info.Id == id);
if (install == default((InstallationInfo, CancellationTokenSource))) if (install == default((InstallationInfo, CancellationTokenSource)))
{ {
return false; return false;
@ -512,7 +512,7 @@ namespace Emby.Server.Implementations.Updates
var compatibleVersions = GetCompatibleVersions(pluginCatalog, plugin.Name, plugin.Id, minVersion: plugin.Version); var compatibleVersions = GetCompatibleVersions(pluginCatalog, plugin.Name, plugin.Id, minVersion: plugin.Version);
var version = compatibleVersions.FirstOrDefault(y => y.Version > plugin.Version); var version = compatibleVersions.FirstOrDefault(y => y.Version > plugin.Version);
if (version != null && CompletedInstallations.All(x => x.Guid != version.Guid)) if (version != null && CompletedInstallations.All(x => x.Id != version.Id))
{ {
yield return version; yield return version;
} }
@ -577,7 +577,7 @@ namespace Emby.Server.Implementations.Updates
private async Task<bool> InstallPackageInternal(InstallationInfo package, CancellationToken cancellationToken) private async Task<bool> InstallPackageInternal(InstallationInfo package, CancellationToken cancellationToken)
{ {
// Set last update time if we were installed before // Set last update time if we were installed before
LocalPlugin? plugin = _pluginManager.Plugins.FirstOrDefault(p => p.Id.Equals(package.Guid) && p.Version.Equals(package.Version)) LocalPlugin? plugin = _pluginManager.Plugins.FirstOrDefault(p => p.Id.Equals(package.Id) && p.Version.Equals(package.Version))
?? _pluginManager.Plugins.FirstOrDefault(p => p.Name.Equals(package.Name, StringComparison.OrdinalIgnoreCase) && p.Version.Equals(package.Version)); ?? _pluginManager.Plugins.FirstOrDefault(p => p.Name.Equals(package.Name, StringComparison.OrdinalIgnoreCase) && p.Version.Equals(package.Version));
if (plugin != null) if (plugin != null)
{ {

View File

@ -48,7 +48,7 @@ namespace MediaBrowser.Common.Plugins
var assemblyFilePath = assembly.Location; var assemblyFilePath = assembly.Location;
var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath)); var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(assemblyFilePath));
if (!Directory.Exists(dataFolderPath)) if (!Directory.Exists(dataFolderPath) && Version != null)
{ {
// Try again with the version number appended to the folder name. // Try again with the version number appended to the folder name.
dataFolderPath = dataFolderPath + "_" + Version.ToString(); dataFolderPath = dataFolderPath + "_" + Version.ToString();
@ -137,7 +137,20 @@ namespace MediaBrowser.Common.Plugins
/// Gets the full path to the configuration file. /// Gets the full path to the configuration file.
/// </summary> /// </summary>
/// <value>The configuration file path.</value> /// <value>The configuration file path.</value>
public string ConfigurationFilePath { get; } public string ConfigurationFilePath
{
get
{
var dataFolderPath = Path.Combine(ApplicationPaths.PluginsPath, Path.GetFileNameWithoutExtension(AssemblyFilePath));
if (!Directory.Exists(dataFolderPath) && Version != null)
{
// Try again with the version number appended to the folder name.
return dataFolderPath + "_" + Version.ToString();
}
return dataFolderPath;
}
}
/// <summary> /// <summary>
/// Gets the plugin configuration. /// Gets the plugin configuration.

View File

@ -1,8 +1,6 @@
#nullable enable #nullable enable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Plugins;
namespace MediaBrowser.Common.Plugins namespace MediaBrowser.Common.Plugins
@ -32,7 +30,7 @@ namespace MediaBrowser.Common.Plugins
/// <summary> /// <summary>
/// Gets the plugin id. /// Gets the plugin id.
/// </summary> /// </summary>
public Guid Id => Manifest.Guid; public Guid Id => Manifest.Id;
/// <summary> /// <summary>
/// Gets the plugin name. /// Gets the plugin name.
@ -110,7 +108,7 @@ namespace MediaBrowser.Common.Plugins
/// <returns>A <see cref="PluginInfo"/> instance containing the information.</returns> /// <returns>A <see cref="PluginInfo"/> instance containing the information.</returns>
public PluginInfo GetPluginInfo() public PluginInfo GetPluginInfo()
{ {
var inst = Instance?.GetPluginInfo() ?? new PluginInfo(Manifest.Name, Version, Manifest.Description, Manifest.Guid, true); var inst = Instance?.GetPluginInfo() ?? new PluginInfo(Manifest.Name, Version, Manifest.Description, Manifest.Id, true);
inst.Status = Manifest.Status; inst.Status = Manifest.Status;
inst.HasImage = !string.IsNullOrEmpty(Manifest.ImageUrl); inst.HasImage = !string.IsNullOrEmpty(Manifest.ImageUrl);
return inst; return inst;

View File

@ -1,5 +1,6 @@
#nullable enable #nullable enable
using System; using System;
using System.Text.Json.Serialization;
using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Plugins;
namespace MediaBrowser.Common.Plugins namespace MediaBrowser.Common.Plugins
@ -27,9 +28,8 @@ namespace MediaBrowser.Common.Plugins
/// <summary> /// <summary>
/// Gets or sets the Global Unique Identifier for the plugin. /// Gets or sets the Global Unique Identifier for the plugin.
/// </summary> /// </summary>
#pragma warning disable CA1720 // Identifier contains type name [JsonPropertyName("Guid")]
public Guid Guid { get; set; } public Guid Id { get; set; }
#pragma warning restore CA1720 // Identifier contains type name
/// <summary> /// <summary>
/// Gets or sets the Name of the plugin. /// Gets or sets the Name of the plugin.

View File

@ -1,20 +1,40 @@
#nullable disable #nullable enable
#pragma warning disable CS1591
namespace MediaBrowser.Model.Plugins namespace MediaBrowser.Model.Plugins
{ {
/// <summary>
/// Defines the <see cref="PluginPageInfo" />.
/// </summary>
public class PluginPageInfo public class PluginPageInfo
{ {
public string Name { get; set; } /// <summary>
/// Gets or sets the name.
/// </summary>
public string Name { get; set; } = string.Empty;
public string DisplayName { get; set; } /// <summary>
/// Gets or sets the display name.
/// </summary>
public string? DisplayName { get; set; }
public string EmbeddedResourcePath { get; set; } /// <summary>
/// Gets or sets the resource path.
/// </summary>
public string EmbeddedResourcePath { get; set; } = string.Empty;
/// <summary>
/// Gets or sets a value indicating whether this plugin should appear in the main menu.
/// </summary>
public bool EnableInMainMenu { get; set; } public bool EnableInMainMenu { get; set; }
public string MenuSection { get; set; } /// <summary>
/// Gets or sets the menu section.
/// </summary>
public string? MenuSection { get; set; }
public string MenuIcon { get; set; } /// <summary>
/// Gets or sets the menu icon.
/// </summary>
public string? MenuIcon { get; set; }
} }
} }

View File

@ -1,5 +1,6 @@
#nullable disable #nullable disable
using System; using System;
using System.Text.Json.Serialization;
namespace MediaBrowser.Model.Updates namespace MediaBrowser.Model.Updates
{ {
@ -9,10 +10,11 @@ namespace MediaBrowser.Model.Updates
public class InstallationInfo public class InstallationInfo
{ {
/// <summary> /// <summary>
/// Gets or sets the guid. /// Gets or sets the Id.
/// </summary> /// </summary>
/// <value>The guid.</value> /// <value>The Id.</value>
public Guid Guid { get; set; } [JsonPropertyName("Guid")]
public Guid Id { get; set; }
/// <summary> /// <summary>
/// Gets or sets the name. /// Gets or sets the name.

View File

@ -16,7 +16,7 @@ namespace MediaBrowser.Model.Updates
public PackageInfo() public PackageInfo()
{ {
Versions = Array.Empty<VersionInfo>(); Versions = Array.Empty<VersionInfo>();
Guid = string.Empty; Id = string.Empty;
Category = string.Empty; Category = string.Empty;
Name = string.Empty; Name = string.Empty;
Overview = string.Empty; Overview = string.Empty;
@ -65,9 +65,7 @@ namespace MediaBrowser.Model.Updates
/// </summary> /// </summary>
/// <value>The name.</value> /// <value>The name.</value>
[JsonPropertyName("guid")] [JsonPropertyName("guid")]
#pragma warning disable CA1720 // Identifier contains type name public string Id { get; set; }
public string Guid { get; set; }
#pragma warning restore CA1720 // Identifier contains type name
/// <summary> /// <summary>
/// Gets or sets the versions. /// Gets or sets the versions.

View File

@ -1,4 +1,4 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,4 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,4 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;