Use sync string instead of file
This commit is contained in:
parent
a714008b59
commit
e835dfb27d
|
@ -10,6 +10,7 @@ using System.Net;
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Emby.Dlna;
|
||||
|
@ -100,7 +101,6 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Prometheus.DotNetRuntime;
|
||||
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
||||
using WebSocketManager = Emby.Server.Implementations.HttpServer.WebSocketManager;
|
||||
|
||||
|
@ -1047,8 +1047,8 @@ namespace Emby.Server.Implementations
|
|||
var metafile = Path.Combine(dir, "meta.json");
|
||||
if (File.Exists(metafile))
|
||||
{
|
||||
using FileStream jsonStream = File.OpenRead(metafile);
|
||||
var manifest = JsonSerializer.DeserializeAsync<PluginManifest>(jsonStream, jsonOptions).GetAwaiter().GetResult();
|
||||
var jsonString = File.ReadAllText(metafile);
|
||||
var manifest = JsonSerializer.Deserialize<PluginManifest>(jsonString, jsonOptions);
|
||||
|
||||
if (!Version.TryParse(manifest.TargetAbi, out var targetAbi))
|
||||
{
|
||||
|
|
|
@ -340,8 +340,8 @@ namespace Emby.Server.Implementations.Channels
|
|||
|
||||
try
|
||||
{
|
||||
using FileStream jsonStream = File.OpenRead(path);
|
||||
return JsonSerializer.DeserializeAsync<List<MediaSourceInfo>>(jsonStream, JsonDefaults.GetOptions()).GetAwaiter().GetResult()
|
||||
var jsonString = File.ReadAllText(path);
|
||||
return JsonSerializer.Deserialize<List<MediaSourceInfo>>(jsonString, JsonDefaults.GetOptions())
|
||||
?? new List<MediaSourceInfo>();
|
||||
}
|
||||
catch
|
||||
|
@ -368,6 +368,7 @@ namespace Emby.Server.Implementations.Channels
|
|||
}
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
await using FileStream createStream = File.Create(path);
|
||||
await JsonSerializer.SerializeAsync(createStream, mediaSources, JsonDefaults.GetOptions()).ConfigureAwait(false);
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||
|
||||
try
|
||||
{
|
||||
using FileStream jsonStream = File.OpenRead(_dataPath);
|
||||
_items = JsonSerializer.DeserializeAsync<T[]>(jsonStream, JsonDefaults.GetOptions()).GetAwaiter().GetResult();
|
||||
var jsonString = File.ReadAllText(_dataPath);
|
||||
_items = JsonSerializer.Deserialize<T[]>(jsonString, JsonDefaults.GetOptions());
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -139,8 +139,15 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
|||
{
|
||||
try
|
||||
{
|
||||
using FileStream jsonStream = File.OpenRead(path);
|
||||
_lastExecutionResult = JsonSerializer.DeserializeAsync<TaskResult>(jsonStream, JsonDefaults.GetOptions()).GetAwaiter().GetResult();
|
||||
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);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user