Removed unnecessary configuration options and reduced primitive dependencies
This commit is contained in:
parent
3f80b16ffa
commit
18ae107ce4
|
@ -104,10 +104,10 @@ using MediaBrowser.Providers.Manager;
|
||||||
using MediaBrowser.Providers.Subtitles;
|
using MediaBrowser.Providers.Subtitles;
|
||||||
using MediaBrowser.WebDashboard.Api;
|
using MediaBrowser.WebDashboard.Api;
|
||||||
using MediaBrowser.XbmcMetadata.Providers;
|
using MediaBrowser.XbmcMetadata.Providers;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using ServiceStack.Text.Jsv;
|
|
||||||
using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate;
|
using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations
|
namespace Emby.Server.Implementations
|
||||||
|
@ -318,6 +318,8 @@ namespace Emby.Server.Implementations
|
||||||
private IMediaSourceManager MediaSourceManager { get; set; }
|
private IMediaSourceManager MediaSourceManager { get; set; }
|
||||||
private IPlaylistManager PlaylistManager { get; set; }
|
private IPlaylistManager PlaylistManager { get; set; }
|
||||||
|
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the installation manager.
|
/// Gets or sets the installation manager.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -356,8 +358,10 @@ namespace Emby.Server.Implementations
|
||||||
IFileSystem fileSystem,
|
IFileSystem fileSystem,
|
||||||
IEnvironmentInfo environmentInfo,
|
IEnvironmentInfo environmentInfo,
|
||||||
IImageEncoder imageEncoder,
|
IImageEncoder imageEncoder,
|
||||||
INetworkManager networkManager)
|
INetworkManager networkManager,
|
||||||
|
IConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
_configuration = configuration;
|
||||||
|
|
||||||
// hack alert, until common can target .net core
|
// hack alert, until common can target .net core
|
||||||
BaseExtensions.CryptographyProvider = CryptographyProvider;
|
BaseExtensions.CryptographyProvider = CryptographyProvider;
|
||||||
|
@ -727,11 +731,10 @@ namespace Emby.Server.Implementations
|
||||||
HttpServer = new HttpListenerHost(this,
|
HttpServer = new HttpListenerHost(this,
|
||||||
LoggerFactory,
|
LoggerFactory,
|
||||||
ServerConfigurationManager,
|
ServerConfigurationManager,
|
||||||
"web/index.html",
|
_configuration,
|
||||||
NetworkManager,
|
NetworkManager,
|
||||||
JsonSerializer,
|
JsonSerializer,
|
||||||
XmlSerializer,
|
XmlSerializer);
|
||||||
GetParseFn);
|
|
||||||
|
|
||||||
HttpServer.GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
|
HttpServer.GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
|
||||||
serviceCollection.AddSingleton(HttpServer);
|
serviceCollection.AddSingleton(HttpServer);
|
||||||
|
@ -831,11 +834,6 @@ namespace Emby.Server.Implementations
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Func<string, object> GetParseFn(Type propertyType)
|
|
||||||
{
|
|
||||||
return s => JsvReader.GetParseFn(propertyType)(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual string PackageRuntime => "netcore";
|
public virtual string PackageRuntime => "netcore";
|
||||||
|
|
||||||
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, EnvironmentInfo.EnvironmentInfo environmentInfo)
|
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, EnvironmentInfo.EnvironmentInfo environmentInfo)
|
||||||
|
|
|
@ -6,8 +6,7 @@ namespace Emby.Server.Implementations
|
||||||
{
|
{
|
||||||
public static readonly Dictionary<string, string> Configuration = new Dictionary<string, string>
|
public static readonly Dictionary<string, string> Configuration = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{"ManagedFileSystem:DefaultDirectory", null},
|
{"HttpListenerHost:DefaultRedirectPath", "web/index.html"}
|
||||||
{"ManagedFileSystem:EnableSeparateFileAndDirectoryQueries", "True"}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,9 @@ using MediaBrowser.Model.Events;
|
||||||
using MediaBrowser.Model.Extensions;
|
using MediaBrowser.Model.Extensions;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.Model.Services;
|
using MediaBrowser.Model.Services;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ServiceStack.Text.Jsv;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.HttpServer
|
namespace Emby.Server.Implementations.HttpServer
|
||||||
{
|
{
|
||||||
|
@ -53,20 +55,20 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
IServerApplicationHost applicationHost,
|
IServerApplicationHost applicationHost,
|
||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
IServerConfigurationManager config,
|
IServerConfigurationManager config,
|
||||||
string defaultRedirectPath,
|
IConfiguration configuration,
|
||||||
INetworkManager networkManager,
|
INetworkManager networkManager,
|
||||||
IJsonSerializer jsonSerializer,
|
IJsonSerializer jsonSerializer,
|
||||||
IXmlSerializer xmlSerializer,
|
IXmlSerializer xmlSerializer)
|
||||||
Func<Type, Func<string, object>> funcParseFn)
|
|
||||||
{
|
{
|
||||||
_appHost = applicationHost;
|
_appHost = applicationHost;
|
||||||
_logger = loggerFactory.CreateLogger("HttpServer");
|
_logger = loggerFactory.CreateLogger("HttpServer");
|
||||||
_config = config;
|
_config = config;
|
||||||
DefaultRedirectPath = defaultRedirectPath;
|
DefaultRedirectPath = configuration["HttpListenerHost:DefaultRedirectPath"];
|
||||||
_networkManager = networkManager;
|
_networkManager = networkManager;
|
||||||
_jsonSerializer = jsonSerializer;
|
_jsonSerializer = jsonSerializer;
|
||||||
_xmlSerializer = xmlSerializer;
|
_xmlSerializer = xmlSerializer;
|
||||||
_funcParseFn = funcParseFn;
|
|
||||||
|
_funcParseFn = t => s => JsvReader.GetParseFn(t)(s);
|
||||||
|
|
||||||
Instance = this;
|
Instance = this;
|
||||||
ResponseFilters = Array.Empty<Action<IRequest, IResponse, object>>();
|
ResponseFilters = Array.Empty<Action<IRequest, IResponse, object>>();
|
||||||
|
|
|
@ -22,61 +22,27 @@ namespace Emby.Server.Implementations.IO
|
||||||
private readonly bool _supportsAsyncFileStreams;
|
private readonly bool _supportsAsyncFileStreams;
|
||||||
private char[] _invalidFileNameChars;
|
private char[] _invalidFileNameChars;
|
||||||
private readonly List<IShortcutHandler> _shortcutHandlers = new List<IShortcutHandler>();
|
private readonly List<IShortcutHandler> _shortcutHandlers = new List<IShortcutHandler>();
|
||||||
private readonly bool EnableSeparateFileAndDirectoryQueries;
|
|
||||||
|
|
||||||
private readonly string _tempPath;
|
private readonly string _tempPath;
|
||||||
|
|
||||||
private readonly IEnvironmentInfo _environmentInfo;
|
private readonly IEnvironmentInfo _environmentInfo;
|
||||||
private readonly bool _isEnvironmentCaseInsensitive;
|
private readonly bool _isEnvironmentCaseInsensitive;
|
||||||
|
|
||||||
private readonly string _defaultDirectory;
|
|
||||||
|
|
||||||
public ManagedFileSystem(
|
public ManagedFileSystem(
|
||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
IEnvironmentInfo environmentInfo,
|
IEnvironmentInfo environmentInfo,
|
||||||
IApplicationPaths applicationPaths,
|
IApplicationPaths applicationPaths)
|
||||||
IConfiguration configuration)
|
|
||||||
{
|
{
|
||||||
Logger = loggerFactory.CreateLogger("FileSystem");
|
Logger = loggerFactory.CreateLogger("FileSystem");
|
||||||
_supportsAsyncFileStreams = true;
|
_supportsAsyncFileStreams = true;
|
||||||
_tempPath = applicationPaths.TempDirectory;
|
_tempPath = applicationPaths.TempDirectory;
|
||||||
_environmentInfo = environmentInfo;
|
_environmentInfo = environmentInfo;
|
||||||
_defaultDirectory = configuration["ManagedFileSystem:DefaultDirectory"];
|
|
||||||
|
|
||||||
// On Linux with mono, this needs to be true or symbolic links are ignored
|
|
||||||
EnableSeparateFileAndDirectoryQueries =
|
|
||||||
bool.Parse(configuration["ManagedFileSystem:EnableSeparateFileAndDirectoryQueries"]);
|
|
||||||
|
|
||||||
SetInvalidFileNameChars(environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows);
|
SetInvalidFileNameChars(environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows);
|
||||||
|
|
||||||
_isEnvironmentCaseInsensitive = environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows;
|
_isEnvironmentCaseInsensitive = environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string DefaultDirectory
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var value = _defaultDirectory;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(value))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (Directory.Exists(value))
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void AddShortcutHandler(IShortcutHandler handler)
|
public virtual void AddShortcutHandler(IShortcutHandler handler)
|
||||||
{
|
{
|
||||||
_shortcutHandlers.Add(handler);
|
_shortcutHandlers.Add(handler);
|
||||||
|
@ -779,15 +745,10 @@ namespace Emby.Server.Implementations.IO
|
||||||
var directoryInfo = new DirectoryInfo(path);
|
var directoryInfo = new DirectoryInfo(path);
|
||||||
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||||
|
|
||||||
if (EnableSeparateFileAndDirectoryQueries)
|
|
||||||
{
|
|
||||||
return ToMetadata(directoryInfo.EnumerateDirectories("*", searchOption))
|
return ToMetadata(directoryInfo.EnumerateDirectories("*", searchOption))
|
||||||
.Concat(ToMetadata(directoryInfo.EnumerateFiles("*", searchOption)));
|
.Concat(ToMetadata(directoryInfo.EnumerateFiles("*", searchOption)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ToMetadata(directoryInfo.EnumerateFileSystemInfos("*", searchOption));
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<FileSystemMetadata> ToMetadata(IEnumerable<FileSystemInfo> infos)
|
private IEnumerable<FileSystemMetadata> ToMetadata(IEnumerable<FileSystemInfo> infos)
|
||||||
{
|
{
|
||||||
return infos.Select(GetFileSystemMetadata);
|
return infos.Select(GetFileSystemMetadata);
|
||||||
|
|
|
@ -5,14 +5,31 @@ using Emby.Server.Implementations.HttpServer;
|
||||||
using Jellyfin.Server.SocketSharp;
|
using Jellyfin.Server.SocketSharp;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.System;
|
using MediaBrowser.Model.System;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Jellyfin.Server
|
namespace Jellyfin.Server
|
||||||
{
|
{
|
||||||
public class CoreAppHost : ApplicationHost
|
public class CoreAppHost : ApplicationHost
|
||||||
{
|
{
|
||||||
public CoreAppHost(ServerApplicationPaths applicationPaths, ILoggerFactory loggerFactory, StartupOptions options, IFileSystem fileSystem, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, MediaBrowser.Common.Net.INetworkManager networkManager)
|
public CoreAppHost(
|
||||||
: base(applicationPaths, loggerFactory, options, fileSystem, environmentInfo, imageEncoder, networkManager)
|
ServerApplicationPaths applicationPaths,
|
||||||
|
ILoggerFactory loggerFactory,
|
||||||
|
StartupOptions options,
|
||||||
|
IFileSystem fileSystem,
|
||||||
|
IEnvironmentInfo environmentInfo,
|
||||||
|
MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder,
|
||||||
|
MediaBrowser.Common.Net.INetworkManager networkManager,
|
||||||
|
IConfiguration configuration)
|
||||||
|
: base(
|
||||||
|
applicationPaths,
|
||||||
|
loggerFactory,
|
||||||
|
options,
|
||||||
|
fileSystem,
|
||||||
|
environmentInfo,
|
||||||
|
imageEncoder,
|
||||||
|
networkManager,
|
||||||
|
configuration)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace Jellyfin.Server
|
||||||
// Allow all https requests
|
// Allow all https requests
|
||||||
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; } );
|
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; } );
|
||||||
|
|
||||||
var fileSystem = new ManagedFileSystem(_loggerFactory, environmentInfo, appPaths, appConfig);
|
var fileSystem = new ManagedFileSystem(_loggerFactory, environmentInfo, appPaths);
|
||||||
|
|
||||||
using (var appHost = new CoreAppHost(
|
using (var appHost = new CoreAppHost(
|
||||||
appPaths,
|
appPaths,
|
||||||
|
@ -135,7 +135,8 @@ namespace Jellyfin.Server
|
||||||
fileSystem,
|
fileSystem,
|
||||||
environmentInfo,
|
environmentInfo,
|
||||||
new NullImageEncoder(),
|
new NullImageEncoder(),
|
||||||
new NetworkManager(_loggerFactory, environmentInfo)))
|
new NetworkManager(_loggerFactory, environmentInfo),
|
||||||
|
appConfig))
|
||||||
{
|
{
|
||||||
await appHost.Init(new ServiceCollection()).ConfigureAwait(false);
|
await appHost.Init(new ServiceCollection()).ConfigureAwait(false);
|
||||||
|
|
||||||
|
|
|
@ -173,14 +173,8 @@ namespace MediaBrowser.Api
|
||||||
_fileSystem.DeleteFile(file);
|
_fileSystem.DeleteFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetDefaultDirectoryBrowser request)
|
public object Get(GetDefaultDirectoryBrowser request) =>
|
||||||
{
|
ToOptimizedResult(new DefaultDirectoryBrowserInfo {Path = null});
|
||||||
var result = new DefaultDirectoryBrowserInfo();
|
|
||||||
|
|
||||||
result.Path = _fileSystem.DefaultDirectory;
|
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the specified request.
|
/// Gets the specified request.
|
||||||
|
|
|
@ -113,8 +113,6 @@ namespace MediaBrowser.Model.IO
|
||||||
Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share,
|
Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share,
|
||||||
FileOpenOptions fileOpenOptions);
|
FileOpenOptions fileOpenOptions);
|
||||||
|
|
||||||
string DefaultDirectory { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Swaps the files.
|
/// Swaps the files.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user