aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/ResourceFileManager.cs
diff options
context:
space:
mode:
authorWWWesten <4700006+WWWesten@users.noreply.github.com>2021-11-01 23:43:29 +0500
committerGitHub <noreply@github.com>2021-11-01 23:43:29 +0500
commit0a14279e2a21bcb9654a06a2d49e1e4f0cc5329c (patch)
treee1b1bd603b011ca98e5793e356326bf4a35a7050 /Emby.Server.Implementations/ResourceFileManager.cs
parentf2817fef743eeb75a00782ceea363b2d3e7dc9f2 (diff)
parent76eeb8f655424d295e73ced8349c6fefee6ddb12 (diff)
Merge branch 'jellyfin:master' into master
Diffstat (limited to 'Emby.Server.Implementations/ResourceFileManager.cs')
-rw-r--r--Emby.Server.Implementations/ResourceFileManager.cs65
1 files changed, 0 insertions, 65 deletions
diff --git a/Emby.Server.Implementations/ResourceFileManager.cs b/Emby.Server.Implementations/ResourceFileManager.cs
deleted file mode 100644
index 890d848f4..000000000
--- a/Emby.Server.Implementations/ResourceFileManager.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-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
-{
- public class ResourceFileManager : IResourceFileManager
- {
- private readonly IFileSystem _fileSystem;
- private readonly ILogger _logger;
- private readonly IHttpResultFactory _resultFactory;
-
- public ResourceFileManager(
- IHttpResultFactory resultFactory,
- ILoggerFactory loggerFactory,
- IFileSystem fileSystem)
- {
- _resultFactory = resultFactory;
- _logger = loggerFactory.CreateLogger("ResourceManager");
- _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)
- {
- var fullPath = Path.Combine(basePath, virtualPath.Replace('/', Path.DirectorySeparatorChar));
-
- try
- {
- fullPath = Path.GetFullPath(fullPath);
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error in Path.GetFullPath");
- }
-
- // Don't allow file system access outside of the source folder
- if (!_fileSystem.ContainsSubPath(basePath, fullPath))
- {
- throw new SecurityException("Access denied");
- }
-
- return fullPath;
- }
- }
-}