mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-17 22:43:07 +03:00
Merge branch 'master' into culture
This commit is contained in:
@@ -286,28 +286,18 @@ namespace Emby.Server.Implementations.HttpClientManager
|
||||
|
||||
private HttpResponseInfo GetCachedResponse(string responseCachePath, TimeSpan cacheLength, string url)
|
||||
{
|
||||
try
|
||||
if (File.Exists(responseCachePath)
|
||||
&& _fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow)
|
||||
{
|
||||
if (_fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow)
|
||||
var stream = _fileSystem.GetFileStream(responseCachePath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.Read, true);
|
||||
|
||||
return new HttpResponseInfo
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user