allow separate configuration of app resources path

This commit is contained in:
Luke Pulverenti 2014-11-26 15:57:16 -05:00
parent 17081767da
commit 63a0d52fd1
7 changed files with 25 additions and 29 deletions

View file

@ -14,24 +14,12 @@ namespace MediaBrowser.Common.Implementations
/// </summary> /// </summary>
protected BaseApplicationPaths(string programDataPath, string applicationPath) protected BaseApplicationPaths(string programDataPath, string applicationPath)
{ {
_programDataPath = programDataPath; ProgramDataPath = programDataPath;
ApplicationPath = applicationPath; ApplicationPath = applicationPath;
} }
public string ApplicationPath { get; private set; } public string ApplicationPath { get; private set; }
public string ProgramDataPath { 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; }
}
/// <summary> /// <summary>
/// Gets the path to the system folder /// Gets the path to the system folder

View file

@ -10,6 +10,13 @@ namespace MediaBrowser.Controller
/// <value>The root folder path.</value> /// <value>The root folder path.</value>
string RootFolderPath { get; } 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> /// <summary>
/// Gets the path to the default user view directory. Used if no specific user view is defined. /// Gets the path to the default user view directory. Used if no specific user view is defined.
/// </summary> /// </summary>

View file

@ -1,4 +1,4 @@
using MediaBrowser.Common.Configuration; using MediaBrowser.Controller;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
using ServiceStack.Web; using ServiceStack.Web;
using System.IO; using System.IO;
@ -7,9 +7,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{ {
public class SwaggerService : IHasResultFactory, IRestfulService public class SwaggerService : IHasResultFactory, IRestfulService
{ {
private readonly IApplicationPaths _appPaths; private readonly IServerApplicationPaths _appPaths;
public SwaggerService(IApplicationPaths appPaths) public SwaggerService(IServerApplicationPaths appPaths)
{ {
_appPaths = appPaths; _appPaths = appPaths;
} }
@ -21,9 +21,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// <returns>System.Object.</returns> /// <returns>System.Object.</returns>
public object Get(GetSwaggerResource request) public object Get(GetSwaggerResource request)
{ {
var runningDirectory = Path.GetDirectoryName(_appPaths.ApplicationPath); var swaggerDirectory = Path.Combine(_appPaths.ApplicationResourcesPath, "swagger-ui");
var swaggerDirectory = Path.Combine(runningDirectory, "swagger-ui");
var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', Path.DirectorySeparatorChar)); var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', Path.DirectorySeparatorChar));

View file

@ -12,12 +12,14 @@ namespace MediaBrowser.Server.Implementations
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class. /// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.
/// </summary> /// </summary>
public ServerApplicationPaths(string programDataPath, string applicationPath) public ServerApplicationPaths(string programDataPath, string applicationPath, string applicationResourcesPath)
: base(programDataPath, applicationPath) : base(programDataPath, applicationPath)
{ {
ApplicationResourcesPath = applicationResourcesPath;
} }
public string ApplicationResourcesPath { get; private set; }
/// <summary> /// <summary>
/// Gets the path to the base root media directory /// Gets the path to the base root media directory
/// </summary> /// </summary>

View file

@ -1,3 +1,4 @@
using System.IO;
using MediaBrowser.Common.Implementations.IO; using MediaBrowser.Common.Implementations.IO;
using MediaBrowser.Common.Implementations.Logging; using MediaBrowser.Common.Implementations.Logging;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
@ -58,10 +59,10 @@ namespace MediaBrowser.Server.Mono
{ {
if (string.IsNullOrEmpty(programDataPath)) 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>(); private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();

View file

@ -153,16 +153,18 @@ namespace MediaBrowser.ServerApplication
/// <returns>ServerApplicationPaths.</returns> /// <returns>ServerApplicationPaths.</returns>
private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, bool runAsService) private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, bool runAsService)
{ {
var resourcesPath = Path.GetDirectoryName(applicationPath);
if (runAsService) if (runAsService)
{ {
var systemPath = Path.GetDirectoryName(applicationPath); var systemPath = Path.GetDirectoryName(applicationPath);
var programDataPath = Path.GetDirectoryName(systemPath); 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> /// <summary>

View file

@ -87,9 +87,7 @@ namespace MediaBrowser.WebDashboard.Api
return _config.Configuration.DashboardSourcePath; return _config.Configuration.DashboardSourcePath;
} }
var runningDirectory = Path.GetDirectoryName(_config.ApplicationPaths.ApplicationPath); return Path.Combine(_config.ApplicationPaths.ApplicationResourcesPath, "dashboard-ui");
return Path.Combine(runningDirectory, "dashboard-ui");
} }
} }