diff options
| author | Cody Robibero <cody@robibe.ro> | 2021-10-08 07:49:40 -0600 |
|---|---|---|
| committer | Cody Robibero <cody@robibe.ro> | 2021-10-08 07:49:40 -0600 |
| commit | 3bbd98cc3fb4e69b5d5471ab7cbdcc22d59a8eb9 (patch) | |
| tree | d6a0aeb4896ec9ab4305916f0380606483180786 /Jellyfin.Api/Controllers/RemoteImageController.cs | |
| parent | 7a7fe3e681eca87cde631336c9af565fd6dfe0d7 (diff) | |
| parent | a01f9775fffaacfd0fc03b24bff366b4701fe45e (diff) | |
Merge remote-tracking branch 'upstream/master' into schedules-direct
Diffstat (limited to 'Jellyfin.Api/Controllers/RemoteImageController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/RemoteImageController.cs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Jellyfin.Api/Controllers/RemoteImageController.cs b/Jellyfin.Api/Controllers/RemoteImageController.cs index ec836f43e..8a33b12f4 100644 --- a/Jellyfin.Api/Controllers/RemoteImageController.cs +++ b/Jellyfin.Api/Controllers/RemoteImageController.cs @@ -4,11 +4,10 @@ using System.ComponentModel.DataAnnotations; using System.IO; using System.Linq; using System.Net.Http; -using System.Net.Mime; using System.Threading; using System.Threading.Tasks; -using Jellyfin.Api.Attributes; using Jellyfin.Api.Constants; +using Jellyfin.Extensions; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller; @@ -16,7 +15,6 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Net; using MediaBrowser.Model.Providers; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; @@ -202,13 +200,13 @@ namespace Jellyfin.Api.Controllers throw new ResourceNotFoundException(nameof(response.Content.Headers.ContentType)); } - var ext = response.Content.Headers.ContentType.MediaType.Split('/')[^1]; + var ext = response.Content.Headers.ContentType.MediaType.AsSpan().RightPart('/').ToString(); var fullCachePath = GetFullCachePath(urlHash + "." + ext); var fullCacheDirectory = Path.GetDirectoryName(fullCachePath) ?? throw new ResourceNotFoundException($"Provided path ({fullCachePath}) is not valid."); Directory.CreateDirectory(fullCacheDirectory); // use FileShare.None as this bypasses dotnet bug dotnet/runtime#42790 . - await using var fileStream = new FileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, true); + await using var fileStream = new FileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.None, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous); await response.Content.CopyToAsync(fileStream).ConfigureAwait(false); var pointerCacheDirectory = Path.GetDirectoryName(pointerCachePath) ?? throw new ArgumentException($"Provided path ({pointerCachePath}) is not valid.", nameof(pointerCachePath)); |
