aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Plugins/PluginManager.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2021-01-12 16:03:13 +0100
committerBond_009 <bond.009@outlook.com>2021-01-12 16:03:13 +0100
commit1fdd2d6e0527a7b112ed6d79d8854f6fbe6fdaca (patch)
tree0b205a883c23e291f6a04d129ed8cc004593db95 /Emby.Server.Implementations/Plugins/PluginManager.cs
parent1ea2b200c0b38f9d9a058f5e4b6e27815a016860 (diff)
Handle IO errors in LoadManifest
Diffstat (limited to 'Emby.Server.Implementations/Plugins/PluginManager.cs')
-rw-r--r--Emby.Server.Implementations/Plugins/PluginManager.cs32
1 files changed, 19 insertions, 13 deletions
diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.cs
index e7fcc1f58..c4598f281 100644
--- a/Emby.Server.Implementations/Plugins/PluginManager.cs
+++ b/Emby.Server.Implementations/Plugins/PluginManager.cs
@@ -512,30 +512,36 @@ namespace Emby.Server.Implementations.Plugins
var metafile = Path.Combine(dir, "meta.json");
if (File.Exists(metafile))
{
+ // Only path where this stays null is when File.ReadAllBytes throws an IOException
+ byte[] data = null!;
try
{
- var data = File.ReadAllBytes(metafile);
+ data = File.ReadAllBytes(metafile);
manifest = JsonSerializer.Deserialize<PluginManifest>(data, _jsonOptions);
}
- catch (JsonException ex)
+ catch (IOException ex)
{
- _logger.LogError(ex, "Error deserializing {Path}.", dir);
+ _logger.LogError(ex, "Error reading file {Path}.", dir);
}
- }
-
- if (manifest != null)
- {
- if (!Version.TryParse(manifest.TargetAbi, out var targetAbi))
+ catch (JsonException ex)
{
- targetAbi = _minimumVersion;
+ _logger.LogError(ex, "Error deserializing {Json}.", Encoding.UTF8.GetString(data!));
}
- if (!Version.TryParse(manifest.Version, out version))
+ if (manifest != null)
{
- manifest.Version = _minimumVersion.ToString();
- }
+ if (!Version.TryParse(manifest.TargetAbi, out var targetAbi))
+ {
+ targetAbi = _minimumVersion;
+ }
+
+ if (!Version.TryParse(manifest.Version, out version))
+ {
+ manifest.Version = _minimumVersion.ToString();
+ }
- return new LocalPlugin(dir, _appVersion >= targetAbi, manifest);
+ return new LocalPlugin(dir, _appVersion >= targetAbi, manifest);
+ }
}
// No metafile, so lets see if the folder is versioned.