The Free Software Media System - Server Backend & API
allow separate configuration of app resources path
Luke Pulverenti63a0d52fd115
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs b/MediaBrowser.Common.Implementations/BaseApplicationPaths.csindex 2940f921c8..4ad63b2e3f 100644--- a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs+++ b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs@@ -14,24 +14,12 @@ namespace MediaBrowser.Common.Implementations/// </summary>protected BaseApplicationPaths(string programDataPath, string applicationPath){- _programDataPath = programDataPath;+ ProgramDataPath = programDataPath;ApplicationPath = applicationPath;}public string ApplicationPath { get; private set; }-- /// <summary>- /// The _program data path- /// </summary>- private readonly string _programDataPath;- /// <summary>- /// Gets the path to the program data folder- /// </summary>- /// <value>The program data path.</value>- public string ProgramDataPath- {- get { return _programDataPath; }- }+ public string ProgramDataPath { get; private set; }/// <summary>/// Gets the path to the system folderdiff --git a/MediaBrowser.Controller/IServerApplicationPaths.cs b/MediaBrowser.Controller/IServerApplicationPaths.csindex 34137088fd..e3438c3d25 100644--- a/MediaBrowser.Controller/IServerApplicationPaths.cs+++ b/MediaBrowser.Controller/IServerApplicationPaths.cs@@ -10,6 +10,13 @@ namespace MediaBrowser.Controller/// <value>The root folder path.</value>string RootFolderPath { get; }+ /// <summary>+ /// Gets the application resources path. This is the path to the folder containing resources that are deployed as part of the application+ /// For example, this folder contains dashboard-ui and swagger-ui+ /// </summary>+ /// <value>The application resources path.</value>+ string ApplicationResourcesPath { get; }+/// <summary>/// Gets the path to the default user view directory. Used if no specific user view is defined./// </summary>diff --git a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs b/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.csindex 3764697f1e..aeaac80e88 100644--- a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs@@ -1,4 +1,4 @@-using MediaBrowser.Common.Configuration;+using MediaBrowser.Controller;using MediaBrowser.Controller.Net;using ServiceStack.Web;using System.IO;@@ -7,9 +7,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer{public class SwaggerService : IHasResultFactory, IRestfulService{- private readonly IApplicationPaths _appPaths;+ private readonly IServerApplicationPaths _appPaths;- public SwaggerService(IApplicationPaths appPaths)+ public SwaggerService(IServerApplicationPaths appPaths){_appPaths = appPaths;}@@ -21,9 +21,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer/// <returns>System.Object.</returns>public object Get(GetSwaggerResource request){- var runningDirectory = Path.GetDirectoryName(_appPaths.ApplicationPath);-- var swaggerDirectory = Path.Combine(runningDirectory, "swagger-ui");+ var swaggerDirectory = Path.Combine(_appPaths.ApplicationResourcesPath, "swagger-ui");var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', Path.DirectorySeparatorChar));diff --git a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs b/MediaBrowser.Server.Implementations/ServerApplicationPaths.csindex 68956be183..d9973afe78 100644--- a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs+++ b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs@@ -12,12 +12,14 @@ namespace MediaBrowser.Server.Implementations/// <summary>/// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class./// </summary>- public ServerApplicationPaths(string programDataPath, string applicationPath)+ public ServerApplicationPaths(string programDataPath, string applicationPath, string applicationResourcesPath): base(programDataPath, applicationPath){-+ ApplicationResourcesPath = applicationResourcesPath;}+ public string ApplicationResourcesPath { get; private set; }+/// <summary>/// Gets the path to the base root media directory/// </summary>diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.csindex 0df213d900..1cd0b5ae6b 100644--- a/MediaBrowser.Server.Mono/Program.cs+++ b/MediaBrowser.Server.Mono/Program.cs@@ -1,3 +1,4 @@+using System.IO;using MediaBrowser.Common.Implementations.IO;using MediaBrowser.Common.Implementations.Logging;using MediaBrowser.Model.Logging;@@ -58,10 +59,10 @@ namespace MediaBrowser.Server.Mono{if (string.IsNullOrEmpty(programDataPath)){- return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), applicationPath);+ programDataPath = ApplicationPathHelper.GetProgramDataPath(applicationPath);}- return new ServerApplicationPaths(programDataPath, applicationPath);+ return new ServerApplicationPaths(programDataPath, applicationPath, Path.GetDirectoryName(applicationPath));}private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.csindex 36430e642f..af0219bda9 100644--- a/MediaBrowser.ServerApplication/MainStartup.cs+++ b/MediaBrowser.ServerApplication/MainStartup.cs@@ -153,16 +153,18 @@ namespace MediaBrowser.ServerApplication/// <returns>ServerApplicationPaths.</returns>private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, bool runAsService){+ var resourcesPath = Path.GetDirectoryName(applicationPath);+if (runAsService){var systemPath = Path.GetDirectoryName(applicationPath);var programDataPath = Path.GetDirectoryName(systemPath);- return new ServerApplicationPaths(programDataPath, applicationPath);+ return new ServerApplicationPaths(programDataPath, applicationPath, resourcesPath);}- return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), applicationPath);+ return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), applicationPath, resourcesPath);}/// <summary>diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.csindex ff61af0f30..39fcce57d7 100644--- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs+++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs@@ -87,9 +87,7 @@ namespace MediaBrowser.WebDashboard.Apireturn _config.Configuration.DashboardSourcePath;}- var runningDirectory = Path.GetDirectoryName(_config.ApplicationPaths.ApplicationPath);-- return Path.Combine(runningDirectory, "dashboard-ui");+ return Path.Combine(_config.ApplicationPaths.ApplicationResourcesPath, "dashboard-ui");}}