aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Images/RemoteImageService.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-12-18 00:44:33 -0500
committerGitHub <noreply@github.com>2016-12-18 00:44:33 -0500
commite7cebb91a73354dc3e0d0b6340c9fbd6511f4406 (patch)
tree6f1c368c766c17b7514fe749c0e92e69cd89194a /MediaBrowser.Api/Images/RemoteImageService.cs
parent025905a3e4d50b9a2e07fbf4ff0a203af6604ced (diff)
parentaaa027f3229073e9a40756c3157d41af2a442922 (diff)
Merge pull request #2350 from MediaBrowser/beta
Beta
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>