mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-31 20:24:21 -04:00
Use UTF8 encoding and async correctly
This commit is contained in:
parent
8ac1ed16ca
commit
3dec1fd6b2
@ -10,6 +10,7 @@ using System.Net;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -1047,7 +1048,7 @@ namespace Emby.Server.Implementations
|
|||||||
var metafile = Path.Combine(dir, "meta.json");
|
var metafile = Path.Combine(dir, "meta.json");
|
||||||
if (File.Exists(metafile))
|
if (File.Exists(metafile))
|
||||||
{
|
{
|
||||||
var jsonString = File.ReadAllText(metafile);
|
var jsonString = File.ReadAllText(metafile, Encoding.UTF8);
|
||||||
var manifest = JsonSerializer.Deserialize<PluginManifest>(jsonString, _jsonOptions);
|
var manifest = JsonSerializer.Deserialize<PluginManifest>(jsonString, _jsonOptions);
|
||||||
|
|
||||||
if (!Version.TryParse(manifest.TargetAbi, out var targetAbi))
|
if (!Version.TryParse(manifest.TargetAbi, out var targetAbi))
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -341,7 +342,7 @@ namespace Emby.Server.Implementations.Channels
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var jsonString = File.ReadAllText(path);
|
var jsonString = File.ReadAllText(path, Encoding.UTF8);
|
||||||
return JsonSerializer.Deserialize<List<MediaSourceInfo>>(jsonString, _jsonOptions)
|
return JsonSerializer.Deserialize<List<MediaSourceInfo>>(jsonString, _jsonOptions)
|
||||||
?? new List<MediaSourceInfo>();
|
?? new List<MediaSourceInfo>();
|
||||||
}
|
}
|
||||||
@ -1180,11 +1181,11 @@ namespace Emby.Server.Implementations.Channels
|
|||||||
{
|
{
|
||||||
if (enableMediaProbe && !info.IsLiveStream && item.HasPathProtocol)
|
if (enableMediaProbe && !info.IsLiveStream && item.HasPathProtocol)
|
||||||
{
|
{
|
||||||
await SaveMediaSources(item, new List<MediaSourceInfo>());
|
await SaveMediaSources(item, new List<MediaSourceInfo>()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await SaveMediaSources(item, info.MediaSources);
|
await SaveMediaSources(item, info.MediaSources).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,9 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Json;
|
using MediaBrowser.Common.Json;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
@ -45,7 +47,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var jsonString = File.ReadAllText(_dataPath);
|
var jsonString = File.ReadAllText(_dataPath, Encoding.UTF8);
|
||||||
_items = JsonSerializer.Deserialize<T[]>(jsonString, _jsonOptions);
|
_items = JsonSerializer.Deserialize<T[]>(jsonString, _jsonOptions);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -61,8 +63,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||||||
private void SaveList()
|
private void SaveList()
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(_dataPath));
|
Directory.CreateDirectory(Path.GetDirectoryName(_dataPath));
|
||||||
using FileStream stream = File.OpenWrite(_dataPath);
|
var jsonString = JsonSerializer.Serialize(_items, _jsonOptions);
|
||||||
JsonSerializer.SerializeAsync(stream, _items, _jsonOptions);
|
File.WriteAllText(_dataPath, jsonString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IReadOnlyList<T> GetAll()
|
public IReadOnlyList<T> GetAll()
|
||||||
|
@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -144,7 +145,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var jsonString = File.ReadAllText(path);
|
var jsonString = File.ReadAllText(path, Encoding.UTF8);
|
||||||
if (!string.IsNullOrWhiteSpace(jsonString))
|
if (!string.IsNullOrWhiteSpace(jsonString))
|
||||||
{
|
{
|
||||||
_lastExecutionResult = JsonSerializer.Deserialize<TaskResult>(jsonString, _jsonOptions);
|
_lastExecutionResult = JsonSerializer.Deserialize<TaskResult>(jsonString, _jsonOptions);
|
||||||
@ -540,7 +541,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
|||||||
TaskTriggerInfo[] list = null;
|
TaskTriggerInfo[] list = null;
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
var jsonString = File.ReadAllText(path);
|
var jsonString = File.ReadAllText(path, Encoding.UTF8);
|
||||||
list = JsonSerializer.Deserialize<TaskTriggerInfo[]>(jsonString, _jsonOptions);
|
list = JsonSerializer.Deserialize<TaskTriggerInfo[]>(jsonString, _jsonOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,7 +579,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
|||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||||
|
|
||||||
var json = JsonSerializer.Serialize(triggers, _jsonOptions);
|
var json = JsonSerializer.Serialize(triggers, _jsonOptions);
|
||||||
File.WriteAllText(path, json);
|
File.WriteAllText(path, json, Encoding.UTF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user