The Free Software Media System - Server Backend & API
Merge remote-tracking branch 'upstream/master' into dotnet-5
crobiberodae4541badc9
diff --cc Jellyfin.Api/Controllers/RemoteImageController.csindex c2bfab175a,331277aec1..5284888d82--- a/Jellyfin.Api/Controllers/RemoteImageController.cs+++ b/Jellyfin.Api/Controllers/RemoteImageController.cs@@@ -249,21 -249,13 +249,21 @@@ namespace Jellyfin.Api.Controller{var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);using var response = await httpClient.GetAsync(url).ConfigureAwait(false);+ if (response.Content.Headers.ContentType?.MediaType == null)+ {+ throw new ResourceNotFoundException(nameof(response.Content.Headers.ContentType));+ }+- var ext = response.Content.Headers.ContentType.MediaType.Split('/').Last();+ var ext = response.Content.Headers.ContentType.MediaType.Split('/')[^1];var fullCachePath = GetFullCachePath(urlHash + "." + ext);- Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));+ var fullCacheDirectory = Path.GetDirectoryName(fullCachePath) ?? throw new ResourceNotFoundException($"Provided path ({fullCachePath}) is not valid.");+ Directory.CreateDirectory(fullCacheDirectory);await using var fileStream = new FileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true);await response.Content.CopyToAsync(fileStream).ConfigureAwait(false);- Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath));++ var pointerCacheDirectory = Path.GetDirectoryName(pointerCachePath) ?? throw new ArgumentException($"Provided path ({pointerCachePath}) is not valid.", nameof(pointerCachePath));+ Directory.CreateDirectory(pointerCacheDirectory);await System.IO.File.WriteAllTextAsync(pointerCachePath, fullCachePath, CancellationToken.None).ConfigureAwait(false);}diff --cc Jellyfin.Api/Helpers/StreamingHelpers.csindex 04b1077277,4e6e981be9..0566f4c4dd--- a/Jellyfin.Api/Helpers/StreamingHelpers.cs+++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs@@@ -83,12 -83,8 +83,12 @@@ namespace Jellyfin.Api.Helper}streamingRequest.StreamOptions = ParseStreamOptions(httpRequest.Query);+ if (httpRequest.Path.Value == null)+ {+ throw new ResourceNotFoundException(nameof(httpRequest.Path));+ }- var url = httpRequest.Path.Value.Split('.').Last();+ var url = httpRequest.Path.Value.Split('.')[^1];if (string.IsNullOrEmpty(streamingRequest.AudioCodec)){diff --cc tests/Jellyfin.Api.Tests/ModelBinders/CommaDelimitedArrayModelBinderTests.csindex 6f3bd91329,82c7f6427d..94f2800d46--- a/tests/Jellyfin.Api.Tests/ModelBinders/CommaDelimitedArrayModelBinderTests.cs+++ b/tests/Jellyfin.Api.Tests/ModelBinders/CommaDelimitedArrayModelBinderTests.cs@@@ -147,10 -148,10 +148,10 @@@ namespace Jellyfin.Api.Tests.ModelBindepublic async Task BindModelAsync_CorrectlyBindsEmptyEnumArrayQuery(){var queryParamName = "test";- var queryParamValues = Array.Empty<TestType>();+ IReadOnlyList<TestType> queryParamValues = Array.Empty<TestType>();var queryParamType = typeof(TestType[]);- var modelBinder = new CommaDelimitedArrayModelBinder();+ var modelBinder = new CommaDelimitedArrayModelBinder(new NullLogger<CommaDelimitedArrayModelBinder>());var valueProvider = new QueryStringValueProvider(new BindingSource(string.Empty, string.Empty, false, false),