diff options
Diffstat (limited to 'MediaBrowser.Api/Images/RemoteImageService.cs')
| -rw-r--r-- | MediaBrowser.Api/Images/RemoteImageService.cs | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs index f6c9c9767..eb871746d 100644 --- a/MediaBrowser.Api/Images/RemoteImageService.cs +++ b/MediaBrowser.Api/Images/RemoteImageService.cs @@ -234,21 +234,18 @@ namespace MediaBrowser.Api.Images try { - using (var reader = new StreamReader(pointerCachePath)) - { - contentPath = await reader.ReadToEndAsync().ConfigureAwait(false); - } + contentPath = _fileSystem.ReadAllText(pointerCachePath); - if (_fileSystem.FileExists(contentPath)) + if (_fileSystem.FileExists(contentPath)) { return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false); } } - catch (DirectoryNotFoundException) + catch (FileNotFoundException) { // Means the file isn't cached yet } - catch (FileNotFoundException) + catch (IOException) { // Means the file isn't cached yet } @@ -256,10 +253,7 @@ namespace MediaBrowser.Api.Images await DownloadImage(request.ImageUrl, urlHash, pointerCachePath).ConfigureAwait(false); // Read the pointer file again - using (var reader = new StreamReader(pointerCachePath)) - { - contentPath = await reader.ReadToEndAsync().ConfigureAwait(false); - } + contentPath = _fileSystem.ReadAllText(pointerCachePath); return await ResultFactory.GetStaticFileResult(Request, contentPath).ConfigureAwait(false); } @@ -294,10 +288,7 @@ namespace MediaBrowser.Api.Images } _fileSystem.CreateDirectory(Path.GetDirectoryName(pointerCachePath)); - using (var writer = new StreamWriter(pointerCachePath)) - { - await writer.WriteAsync(fullCachePath).ConfigureAwait(false); - } + _fileSystem.WriteAllText(pointerCachePath, fullCachePath); } /// <summary> |
