mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Enable local file repositories
This commit is contained in:
parent
356d92cd71
commit
0d4aa6bad6
@ -8,6 +8,7 @@ using System.Linq;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
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;
|
||||||
@ -105,8 +106,20 @@ namespace Emby.Server.Implementations.Updates
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var packages = await _httpClientFactory.CreateClient(NamedClient.Default)
|
List<PackageInfo>? packages;
|
||||||
.GetFromJsonAsync<List<PackageInfo>>(new Uri(manifest), _jsonSerializerOptions, cancellationToken).ConfigureAwait(false);
|
var uri = new Uri(manifest);
|
||||||
|
if (uri.Scheme.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
packages = await _httpClientFactory.CreateClient(NamedClient.Default)
|
||||||
|
.GetFromJsonAsync<List<PackageInfo>>(uri, _jsonSerializerOptions, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Local Packages
|
||||||
|
var data = File.ReadAllText(manifest, Encoding.UTF8);
|
||||||
|
packages = JsonSerializer.Deserialize<List<PackageInfo>>(data, _jsonSerializerOptions);
|
||||||
|
}
|
||||||
|
|
||||||
if (packages == null)
|
if (packages == null)
|
||||||
{
|
{
|
||||||
return Array.Empty<PackageInfo>();
|
return Array.Empty<PackageInfo>();
|
||||||
@ -150,6 +163,11 @@ namespace Emby.Server.Implementations.Updates
|
|||||||
|
|
||||||
return packages;
|
return packages;
|
||||||
}
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Cannot locate the plugin manifest {Manifest}", manifest);
|
||||||
|
return Array.Empty<PackageInfo>();
|
||||||
|
}
|
||||||
catch (JsonException ex)
|
catch (JsonException ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Failed to deserialize the plugin manifest retrieved from {Manifest}", manifest);
|
_logger.LogError(ex, "Failed to deserialize the plugin manifest retrieved from {Manifest}", manifest);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user