aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs5
-rw-r--r--Emby.Server.Implementations/Channels/ChannelManager.cs4
-rw-r--r--Emby.Server.Implementations/Library/LiveStreamHelper.cs4
-rw-r--r--Emby.Server.Implementations/Library/MediaSourceManager.cs4
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs4
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs11
-rw-r--r--MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs4
-rw-r--r--MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs4
-rw-r--r--MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs4
-rw-r--r--MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs4
-rw-r--r--MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs6
11 files changed, 24 insertions, 30 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index fcc156e9c..99cd3b6cc 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -1038,6 +1038,7 @@ namespace Emby.Server.Implementations
}
var directories = Directory.EnumerateDirectories(path, "*.*", SearchOption.TopDirectoryOnly);
+ var jsonOptions = JsonDefaults.GetOptions();
foreach (var dir in directories)
{
@@ -1046,8 +1047,8 @@ namespace Emby.Server.Implementations
var metafile = Path.Combine(dir, "meta.json");
if (File.Exists(metafile))
{
- var jsonString = File.ReadAllText(metafile);
- var manifest = JsonSerializer.Deserialize<PluginManifest>(jsonString, JsonDefaults.GetOptions());
+ using FileStream jsonStream = File.OpenRead(metafile);
+ var manifest = JsonSerializer.DeserializeAsync<PluginManifest>(jsonStream, jsonOptions).GetAwaiter().GetResult();
if (!Version.TryParse(manifest.TargetAbi, out var targetAbi))
{
diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs
index 4e4fbf82c..b462d7bdc 100644
--- a/Emby.Server.Implementations/Channels/ChannelManager.cs
+++ b/Emby.Server.Implementations/Channels/ChannelManager.cs
@@ -340,8 +340,8 @@ namespace Emby.Server.Implementations.Channels
try
{
- var jsonString = File.ReadAllText(path);
- return JsonSerializer.Deserialize<List<MediaSourceInfo>>(jsonString, JsonDefaults.GetOptions()) ?? new List<MediaSourceInfo>();
+ using FileStream jsonStream = File.OpenRead(path);
+ return JsonSerializer.DeserializeAsync<List<MediaSourceInfo>>(jsonStream, JsonDefaults.GetOptions()).GetAwaiter().GetResult();
}
catch
{
diff --git a/Emby.Server.Implementations/Library/LiveStreamHelper.cs b/Emby.Server.Implementations/Library/LiveStreamHelper.cs
index ad7988fb1..3ceba0fe9 100644
--- a/Emby.Server.Implementations/Library/LiveStreamHelper.cs
+++ b/Emby.Server.Implementations/Library/LiveStreamHelper.cs
@@ -46,8 +46,8 @@ namespace Emby.Server.Implementations.Library
{
try
{
- var jsonString = await File.ReadAllTextAsync(cacheFilePath, cancellationToken).ConfigureAwait(false);
- JsonSerializer.Deserialize<MediaInfo>(jsonString, JsonDefaults.GetOptions());
+ await using FileStream jsonStream = File.OpenRead(cacheFilePath);
+ await JsonSerializer.DeserializeAsync<MediaInfo>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
// _logger.LogDebug("Found cached media info");
}
diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs
index 264390dd3..b3900e4aa 100644
--- a/Emby.Server.Implementations/Library/MediaSourceManager.cs
+++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs
@@ -641,8 +641,8 @@ namespace Emby.Server.Implementations.Library
{
try
{
- var json = await File.ReadAllTextAsync(cacheFilePath, cancellationToken).ConfigureAwait(false);
- mediaInfo = JsonSerializer.Deserialize<MediaInfo>(json, JsonDefaults.GetOptions());
+ await using FileStream jsonStream = File.OpenRead(cacheFilePath);
+ mediaInfo = await JsonSerializer.DeserializeAsync<MediaInfo>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
// _logger.LogDebug("Found cached media info");
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
index 5256a0ee7..1b9abaa78 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs
@@ -44,8 +44,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
try
{
- var json = File.ReadAllText(_dataPath);
- _items = JsonSerializer.Deserialize<T[]>(json, JsonDefaults.GetOptions());
+ using FileStream jsonStream = File.OpenRead(_dataPath);
+ _items = JsonSerializer.DeserializeAsync<T[]>(jsonStream, JsonDefaults.GetOptions()).GetAwaiter().GetResult();
return;
}
catch (Exception ex)
diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
index eee7aeea3..a9f459986 100644
--- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
@@ -139,15 +139,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
try
{
- var jsonString = File.ReadAllText(path);
- if (!string.IsNullOrWhiteSpace(jsonString))
- {
- _lastExecutionResult = JsonSerializer.Deserialize<TaskResult>(jsonString, JsonDefaults.GetOptions());
- }
- else
- {
- _logger.LogDebug("Scheduled Task history file {path} is empty. Skipping deserialization.", path);
- }
+ using FileStream jsonStream = File.OpenRead(path);
+ _lastExecutionResult = JsonSerializer.DeserializeAsync<TaskResult>(jsonStream, JsonDefaults.GetOptions()).GetAwaiter().GetResult();
}
catch (Exception ex)
{
diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs
index 605b93788..a5aeba7d2 100644
--- a/MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs
@@ -57,8 +57,8 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
var path = AudioDbAlbumProvider.GetAlbumInfoPath(_config.ApplicationPaths, id);
- var jsonString = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);
- var obj = JsonSerializer.Deserialize<AudioDbAlbumProvider.RootObject>(jsonString, JsonDefaults.GetOptions());
+ await using FileStream jsonStream = File.OpenRead(path);
+ var obj = await JsonSerializer.DeserializeAsync<AudioDbAlbumProvider.RootObject>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
if (obj != null && obj.album != null && obj.album.Count > 0)
{
diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs
index 32ef13547..9a61abc1a 100644
--- a/MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs
+++ b/MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs
@@ -64,8 +64,8 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
var path = GetAlbumInfoPath(_config.ApplicationPaths, id);
- var jsonString = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);
- var obj = JsonSerializer.Deserialize<RootObject>(jsonString, JsonDefaults.GetOptions());
+ await using FileStream jsonStream = File.OpenRead(path);
+ var obj = await JsonSerializer.DeserializeAsync<RootObject>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
if (obj != null && obj.album != null && obj.album.Count > 0)
{
diff --git a/MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs
index f0b8e00f3..639bbe859 100644
--- a/MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs
+++ b/MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs
@@ -59,8 +59,8 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
var path = AudioDbArtistProvider.GetArtistInfoPath(_config.ApplicationPaths, id);
- var jsonString = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);
- var obj = JsonSerializer.Deserialize<AudioDbArtistProvider.RootObject>(jsonString, JsonDefaults.GetOptions());
+ await using FileStream jsonStream = File.OpenRead(path);
+ var obj = await JsonSerializer.DeserializeAsync<AudioDbArtistProvider.RootObject>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
if (obj != null && obj.artists != null && obj.artists.Count > 0)
{
diff --git a/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs
index 2476c8671..71efd194e 100644
--- a/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs
+++ b/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs
@@ -65,8 +65,8 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
var path = GetArtistInfoPath(_config.ApplicationPaths, id);
- var jsonString = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);
- var obj = JsonSerializer.Deserialize<RootObject>(jsonString, JsonDefaults.GetOptions());
+ await using FileStream jsonStream = File.OpenRead(path);
+ var obj = await JsonSerializer.DeserializeAsync<RootObject>(jsonStream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
if (obj != null && obj.artists != null && obj.artists.Count > 0)
{
diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
index bbedffbc7..fa75e4ec4 100644
--- a/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
+++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs
@@ -299,7 +299,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
var jsonOptions = JsonDefaults.GetOptions();
var rootObject = await GetDeserializedOmdbResponse<RootObject>(_httpClientFactory.CreateClient(NamedClient.Default), url, jsonOptions, cancellationToken).ConfigureAwait(false);
Directory.CreateDirectory(Path.GetDirectoryName(path));
- await using FileStream jsonFileStream = File.Create(path);
+ await using FileStream jsonFileStream = File.OpenWrite(path);
await JsonSerializer.SerializeAsync(jsonFileStream, rootObject, jsonOptions, cancellationToken).ConfigureAwait(false);
return path;
@@ -337,7 +337,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
var jsonOptions = JsonDefaults.GetOptions();
var rootObject = await GetDeserializedOmdbResponse<SeasonRootObject>(_httpClientFactory.CreateClient(NamedClient.Default), url, jsonOptions, cancellationToken).ConfigureAwait(false);
Directory.CreateDirectory(Path.GetDirectoryName(path));
- await using FileStream jsonFileStream = File.Create(path);
+ await using FileStream jsonFileStream = File.OpenWrite(path);
await JsonSerializer.SerializeAsync(jsonFileStream, rootObject, jsonOptions, cancellationToken).ConfigureAwait(false);
return path;
@@ -349,7 +349,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
var content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
// OMDb is sending "N/A" for no empty number fields
- content = content.Replace("\"N/A\"", "\"0\"", StringComparison.InvariantCulture);
+ content = content.Replace("\"N/A\"", "\"\"", StringComparison.InvariantCulture);
return JsonSerializer.Deserialize<T>(content, jsonOptions);
}