diff options
| author | Bond_009 <bond.009@outlook.com> | 2020-04-15 11:09:14 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2020-04-15 11:09:14 +0200 |
| commit | fc049caba2ed4db499bd53a2e521550bc45b6ebe (patch) | |
| tree | 95c4870cda0783f51dd8207a86fd5ae906054f77 /MediaBrowser.Api/Images/RemoteImageService.cs | |
| parent | 9cca964b0880dc41792fe27ee03e69609ff2ac7e (diff) | |
| parent | 2eb5775ee3fc0bd98f88e7208798dec4aa63c724 (diff) | |
Merge branch 'master' into nullable3
Diffstat (limited to 'MediaBrowser.Api/Images/RemoteImageService.cs')
| -rw-r--r-- | MediaBrowser.Api/Images/RemoteImageService.cs | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs index 3e4198aae..4a4bf42b1 100644 --- a/MediaBrowser.Api/Images/RemoteImageService.cs +++ b/MediaBrowser.Api/Images/RemoteImageService.cs @@ -260,27 +260,25 @@ 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('/').Last(); - - var fullCachePath = GetFullCachePath(urlHash + "." + ext); + }).ConfigureAwait(false); + var ext = result.ContentType.Split('/').Last(); - 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)) - { - await stream.CopyToAsync(filestream).ConfigureAwait(false); - } + var fullCachePath = GetFullCachePath(urlHash + "." + ext); - Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); - File.WriteAllText(pointerCachePath, fullCachePath); + 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); + await stream.CopyToAsync(filestream).ConfigureAwait(false); } + + Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); + File.WriteAllText(pointerCachePath, fullCachePath); } /// <summary> |
