aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Plugins/PluginManager.cs
diff options
context:
space:
mode:
authorAmbulantRex <21176662+AmbulantRex@users.noreply.github.com>2023-04-16 18:47:57 -0600
committerAmbulantRex <21176662+AmbulantRex@users.noreply.github.com>2023-04-16 18:47:57 -0600
commitc7174255498e28272fbe6d4d6867a774a3327eff (patch)
tree4f0205cbaa118d79d944b028427b25da12e2f6c9 /Emby.Server.Implementations/Plugins/PluginManager.cs
parent92f50054b28c85afbee0dfa99016c4b71548de6f (diff)
Remove unnecessary type extension and handle feedback.
Diffstat (limited to 'Emby.Server.Implementations/Plugins/PluginManager.cs')
-rw-r--r--Emby.Server.Implementations/Plugins/PluginManager.cs13
1 files changed, 7 insertions, 6 deletions
diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.cs
index 10d5ea906..48584ae0c 100644
--- a/Emby.Server.Implementations/Plugins/PluginManager.cs
+++ b/Emby.Server.Implementations/Plugins/PluginManager.cs
@@ -432,7 +432,7 @@ namespace Emby.Server.Implementations.Plugins
ImagePath = imagePath
};
- if (!ReconcileManifest(manifest, path))
+ if (!await ReconcileManifest(manifest, path))
{
// An error occurred during reconciliation and saving could be undesirable.
return false;
@@ -448,7 +448,7 @@ namespace Emby.Server.Implementations.Plugins
/// <param name="manifest">The <see cref="PluginManifest"/> to reconcile against.</param>
/// <param name="path">The plugin path.</param>
/// <returns>The reconciled <see cref="PluginManifest"/>.</returns>
- private bool ReconcileManifest(PluginManifest manifest, string path)
+ private async Task<bool> ReconcileManifest(PluginManifest manifest, string path)
{
try
{
@@ -459,8 +459,9 @@ namespace Emby.Server.Implementations.Plugins
return true;
}
- var data = File.ReadAllBytes(metafile);
- var localManifest = JsonSerializer.Deserialize<PluginManifest>(data, _jsonOptions) ?? new PluginManifest();
+ using var metaStream = File.OpenRead(metafile);
+ var localManifest = await JsonSerializer.DeserializeAsync<PluginManifest>(metaStream, _jsonOptions);
+ localManifest ??= new PluginManifest();
if (!Equals(localManifest.Id, manifest.Id))
{
@@ -483,7 +484,7 @@ namespace Emby.Server.Implementations.Plugins
manifest.Overview = string.IsNullOrEmpty(localManifest.Overview) ? manifest.Overview : localManifest.Overview;
manifest.Owner = string.IsNullOrEmpty(localManifest.Owner) ? manifest.Owner : localManifest.Owner;
manifest.TargetAbi = string.IsNullOrEmpty(localManifest.TargetAbi) ? manifest.TargetAbi : localManifest.TargetAbi;
- manifest.Timestamp = localManifest.Timestamp.IsNullOrDefault() ? manifest.Timestamp : localManifest.Timestamp;
+ manifest.Timestamp = localManifest.Timestamp.Equals(default) ? manifest.Timestamp : localManifest.Timestamp;
manifest.ImagePath = string.IsNullOrEmpty(localManifest.ImagePath) ? manifest.ImagePath : localManifest.ImagePath;
manifest.Assemblies = localManifest.Assemblies;
@@ -842,7 +843,7 @@ namespace Emby.Server.Implementations.Plugins
var canonicalized = Path.Combine(plugin.Path, path).Canonicalize();
// Ensure we stay in the plugin directory.
- if (!canonicalized.StartsWith(plugin.Path.NormalizePath()!, StringComparison.Ordinal))
+ if (!canonicalized.StartsWith(plugin.Path.NormalizePath(), StringComparison.Ordinal))
{
_logger.LogError("Assembly path {Path} is not inside the plugin directory.", path);
return false;