aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Images/RemoteImageService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Api/Images/RemoteImageService.cs')
-rw-r--r--MediaBrowser.Api/Images/RemoteImageService.cs25
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>