diff options
| author | Mark Monteiro <marknr.monteiro@protonmail.com> | 2020-05-17 13:50:44 -0400 |
|---|---|---|
| committer | Mark Monteiro <marknr.monteiro@protonmail.com> | 2020-05-17 13:50:44 -0400 |
| commit | 96acd6481efb25c6f23bc9dd92adaa8da637ab0b (patch) | |
| tree | 6c72c60a99e0376fd17980651b1f0f888270f028 /MediaBrowser.Api/Images/RemoteImageService.cs | |
| parent | 0fb78cf54b51843c54e7ff59d191c490a5b196cd (diff) | |
| parent | 4b4b50f3eedc5be92786cc9d4e0d244999107426 (diff) | |
Merge branch 'master' into externalid-type
Diffstat (limited to 'MediaBrowser.Api/Images/RemoteImageService.cs')
| -rw-r--r-- | MediaBrowser.Api/Images/RemoteImageService.cs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs index f03f5efd8..23bf54712 100644 --- a/MediaBrowser.Api/Images/RemoteImageService.cs +++ b/MediaBrowser.Api/Images/RemoteImageService.cs @@ -261,27 +261,28 @@ namespace MediaBrowser.Api.Images /// <returns>Task.</returns> private async Task DownloadImage(string url, Guid urlHash, string pointerCachePath) { - using (var result = await _httpClient.GetResponse(new HttpRequestOptions + using var result = await _httpClient.GetResponse(new HttpRequestOptions { Url = url, BufferContent = false + }).ConfigureAwait(false); + var ext = result.ContentType.Split('/')[^1]; - }).ConfigureAwait(false)) - { - var ext = result.ContentType.Split('/').Last(); - - var fullCachePath = GetFullCachePath(urlHash + "." + ext); + var fullCachePath = GetFullCachePath(urlHash + "." + ext); - Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath)); - using (var stream = result.Content) - using (var filestream = new FileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true)) + Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath)); + var stream = result.Content; + await using (stream.ConfigureAwait(false)) + { + var filestream = new FileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true); + await using (filestream.ConfigureAwait(false)) { await stream.CopyToAsync(filestream).ConfigureAwait(false); } - - Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); - File.WriteAllText(pointerCachePath, fullCachePath); } + + Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); + File.WriteAllText(pointerCachePath, fullCachePath); } /// <summary> |
