aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-01-30 16:57:15 +0100
committerGitHub <noreply@github.com>2019-01-30 16:57:15 +0100
commit1ea219bf3f5c0708c3afa5fa2d897ca5212b5e04 (patch)
treeb3478e7210659ef7fa1e305e814c188ffd152fea /Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
parenta709cbdc64de36a1ce989636a19344af61d9026d (diff)
parentffcf6bdd3aaad5068decf84b0400e433fdb8323c (diff)
Merge branch 'master' into culture
Diffstat (limited to 'Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs')
-rw-r--r--Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs34
1 files changed, 12 insertions, 22 deletions
diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
index 03066c2cb..6ea1bd08e 100644
--- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
+++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs
@@ -286,28 +286,18 @@ namespace Emby.Server.Implementations.HttpClientManager
private HttpResponseInfo GetCachedResponse(string responseCachePath, TimeSpan cacheLength, string url)
{
- try
- {
- if (_fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow)
- {
- var stream = _fileSystem.GetFileStream(responseCachePath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read, true);
-
- return new HttpResponseInfo
- {
- ResponseUrl = url,
- Content = stream,
- StatusCode = HttpStatusCode.OK,
- ContentLength = stream.Length
- };
- }
- }
- catch (FileNotFoundException) // REVIEW: @bond Is this really faster?
- {
-
- }
- catch (DirectoryNotFoundException)
+ if (File.Exists(responseCachePath)
+ && _fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow)
{
+ var stream = _fileSystem.GetFileStream(responseCachePath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read, true);
+ return new HttpResponseInfo
+ {
+ ResponseUrl = url,
+ Content = stream,
+ StatusCode = HttpStatusCode.OK,
+ ContentLength = stream.Length
+ };
}
return null;
@@ -315,7 +305,7 @@ namespace Emby.Server.Implementations.HttpClientManager
private async Task CacheResponse(HttpResponseInfo response, string responseCachePath)
{
- _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(responseCachePath));
+ Directory.CreateDirectory(Path.GetDirectoryName(responseCachePath));
using (var fileStream = _fileSystem.GetFileStream(responseCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.None, true))
{
@@ -523,7 +513,7 @@ namespace Emby.Server.Implementations.HttpClientManager
{
ValidateParams(options);
- _fileSystem.CreateDirectory(_appPaths.TempDirectory);
+ Directory.CreateDirectory(_appPaths.TempDirectory);
var tempFile = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + ".tmp");