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.cs29
1 files changed, 11 insertions, 18 deletions
diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs
index 25d7639c6..eb871746d 100644
--- a/MediaBrowser.Api/Images/RemoteImageService.cs
+++ b/MediaBrowser.Api/Images/RemoteImageService.cs
@@ -8,14 +8,16 @@ using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers;
-using ServiceStack;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using CommonIO;
+using MediaBrowser.Common.IO;
+using MediaBrowser.Controller.IO;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Services;
namespace MediaBrowser.Api.Images
{
@@ -232,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
}
@@ -254,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);
}
@@ -285,17 +281,14 @@ namespace MediaBrowser.Api.Images
_fileSystem.CreateDirectory(Path.GetDirectoryName(fullCachePath));
using (var stream = result.Content)
{
- using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.Read, true))
+ using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
{
await stream.CopyToAsync(filestream).ConfigureAwait(false);
}
}
_fileSystem.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
- using (var writer = new StreamWriter(pointerCachePath))
- {
- await writer.WriteAsync(fullCachePath).ConfigureAwait(false);
- }
+ _fileSystem.WriteAllText(pointerCachePath, fullCachePath);
}
/// <summary>