diff options
| author | dkanada <dkanada@users.noreply.github.com> | 2019-06-21 23:33:37 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-21 23:33:37 -0700 |
| commit | 1b2621cd30eb22ce6fbc8b94175ce8f5fce0330f (patch) | |
| tree | ef176427d50a1796aebbce944dd4d62da5f9bc44 /Emby.Server.Implementations/ResourceFileManager.cs | |
| parent | dbc2cda9d41eb9dca6f635f3498c14a4e09a84e6 (diff) | |
| parent | 253e72f66720c2f590c443f8347e2187f4f36db0 (diff) | |
Merge pull request #1454 from Bond-009/webresource
Simplify file serving code
Diffstat (limited to 'Emby.Server.Implementations/ResourceFileManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/ResourceFileManager.cs | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/Emby.Server.Implementations/ResourceFileManager.cs b/Emby.Server.Implementations/ResourceFileManager.cs index 890d848f4..6eda2b503 100644 --- a/Emby.Server.Implementations/ResourceFileManager.cs +++ b/Emby.Server.Implementations/ResourceFileManager.cs @@ -1,10 +1,8 @@ using System; using System.IO; -using System.Threading.Tasks; using MediaBrowser.Controller; using MediaBrowser.Controller.Net; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Services; using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations @@ -13,34 +11,14 @@ namespace Emby.Server.Implementations { private readonly IFileSystem _fileSystem; private readonly ILogger _logger; - private readonly IHttpResultFactory _resultFactory; - public ResourceFileManager( - IHttpResultFactory resultFactory, - ILoggerFactory loggerFactory, - IFileSystem fileSystem) + public ResourceFileManager(ILogger<ResourceFileManager> logger, IFileSystem fileSystem) { - _resultFactory = resultFactory; - _logger = loggerFactory.CreateLogger("ResourceManager"); + _logger = logger; _fileSystem = fileSystem; } - public Stream GetResourceFileStream(string basePath, string virtualPath) - { - return _fileSystem.GetFileStream(GetResourcePath(basePath, virtualPath), FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, true); - } - - public Task<object> GetStaticFileResult(IRequest request, string basePath, string virtualPath, string contentType, TimeSpan? cacheDuration) - { - return _resultFactory.GetStaticFileResult(request, GetResourcePath(basePath, virtualPath)); - } - - public string ReadAllText(string basePath, string virtualPath) - { - return File.ReadAllText(GetResourcePath(basePath, virtualPath)); - } - - private string GetResourcePath(string basePath, string virtualPath) + public string GetResourcePath(string basePath, string virtualPath) { var fullPath = Path.Combine(basePath, virtualPath.Replace('/', Path.DirectorySeparatorChar)); @@ -50,7 +28,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - _logger.LogError(ex, "Error in Path.GetFullPath"); + _logger.LogError(ex, "Error retrieving full path"); } // Don't allow file system access outside of the source folder |
