diff options
Diffstat (limited to 'MediaBrowser.Api/Images/RemoteImageService.cs')
| -rw-r--r-- | MediaBrowser.Api/Images/RemoteImageService.cs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs index 413762a5c..4782d76df 100644 --- a/MediaBrowser.Api/Images/RemoteImageService.cs +++ b/MediaBrowser.Api/Images/RemoteImageService.cs @@ -262,28 +262,29 @@ namespace MediaBrowser.Api.Images /// <returns>Task.</returns> private async Task DownloadImage(string url, Guid urlHash, string pointerCachePath) { - 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(); + }).ConfigureAwait(false)) + { + var ext = result.ContentType.Split('/').Last(); - var fullCachePath = GetFullCachePath(urlHash + "." + ext); + var fullCachePath = GetFullCachePath(urlHash + "." + ext); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fullCachePath)); - using (var stream = result.Content) - { - using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) + _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fullCachePath)); + using (var stream = result.Content) { - await stream.CopyToAsync(filestream).ConfigureAwait(false); + using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true)) + { + await stream.CopyToAsync(filestream).ConfigureAwait(false); + } } - } - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(pointerCachePath)); - _fileSystem.WriteAllText(pointerCachePath, fullCachePath); + _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(pointerCachePath)); + _fileSystem.WriteAllText(pointerCachePath, fullCachePath); + } } /// <summary> |
