|
|
|
@ -113,6 +113,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|
|
|
|
private readonly ILocalizationManager _localization;
|
|
|
|
|
private readonly IJsonSerializer _jsonSerializer;
|
|
|
|
|
private readonly IAssemblyInfo _assemblyInfo;
|
|
|
|
|
private readonly IMemoryStreamFactory _memoryStreamFactory;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="DashboardService" /> class.
|
|
|
|
@ -120,7 +121,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|
|
|
|
/// <param name="appHost">The app host.</param>
|
|
|
|
|
/// <param name="serverConfigurationManager">The server configuration manager.</param>
|
|
|
|
|
/// <param name="fileSystem">The file system.</param>
|
|
|
|
|
public DashboardService(IServerApplicationHost appHost, IServerConfigurationManager serverConfigurationManager, IFileSystem fileSystem, ILocalizationManager localization, IJsonSerializer jsonSerializer, IAssemblyInfo assemblyInfo, ILogger logger, IHttpResultFactory resultFactory)
|
|
|
|
|
public DashboardService(IServerApplicationHost appHost, IServerConfigurationManager serverConfigurationManager, IFileSystem fileSystem, ILocalizationManager localization, IJsonSerializer jsonSerializer, IAssemblyInfo assemblyInfo, ILogger logger, IHttpResultFactory resultFactory, IMemoryStreamFactory memoryStreamFactory)
|
|
|
|
|
{
|
|
|
|
|
_appHost = appHost;
|
|
|
|
|
_serverConfigurationManager = serverConfigurationManager;
|
|
|
|
@ -130,6 +131,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|
|
|
|
_assemblyInfo = assemblyInfo;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_resultFactory = resultFactory;
|
|
|
|
|
_memoryStreamFactory = memoryStreamFactory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -161,7 +163,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|
|
|
|
|
|
|
|
|
if (plugin != null && stream != null)
|
|
|
|
|
{
|
|
|
|
|
return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml("dummy.html", stream, null, _appHost.ApplicationVersion.ToString(), null, false));
|
|
|
|
|
return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml("dummy.html", stream, null, _appHost.ApplicationVersion.ToString(), null));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new ResourceNotFoundException();
|
|
|
|
@ -294,7 +296,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|
|
|
|
cacheDuration = TimeSpan.FromDays(365);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cacheKey = (_appHost.ApplicationVersion.ToString() + (localizationCulture ?? string.Empty) + path).GetMD5();
|
|
|
|
|
var cacheKey = (_appHost.ApplicationVersion + (localizationCulture ?? string.Empty) + path).GetMD5();
|
|
|
|
|
|
|
|
|
|
return await _resultFactory.GetStaticResult(Request, cacheKey, null, cacheDuration, contentType, () => GetResourceStream(path, localizationCulture)).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
@ -312,15 +314,13 @@ namespace MediaBrowser.WebDashboard.Api
|
|
|
|
|
/// <returns>Task{Stream}.</returns>
|
|
|
|
|
private Task<Stream> GetResourceStream(string path, string localizationCulture)
|
|
|
|
|
{
|
|
|
|
|
var minify = _serverConfigurationManager.Configuration.EnableDashboardResourceMinification;
|
|
|
|
|
|
|
|
|
|
return GetPackageCreator()
|
|
|
|
|
.GetResource(path, null, localizationCulture, _appHost.ApplicationVersion.ToString(), minify);
|
|
|
|
|
.GetResource(path, null, localizationCulture, _appHost.ApplicationVersion.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private PackageCreator GetPackageCreator()
|
|
|
|
|
{
|
|
|
|
|
return new PackageCreator(_fileSystem, _localization, _logger, _serverConfigurationManager, _jsonSerializer);
|
|
|
|
|
return new PackageCreator(_fileSystem, _logger, _serverConfigurationManager, _memoryStreamFactory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<string> GetDeployIgnoreExtensions()
|
|
|
|
@ -507,7 +507,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|
|
|
|
|
|
|
|
|
private async Task DumpFile(string resourceVirtualPath, string destinationFilePath, string mode, string culture, string appVersion)
|
|
|
|
|
{
|
|
|
|
|
using (var stream = await GetPackageCreator().GetResource(resourceVirtualPath, mode, culture, appVersion, false).ConfigureAwait(false))
|
|
|
|
|
using (var stream = await GetPackageCreator().GetResource(resourceVirtualPath, mode, culture, appVersion).ConfigureAwait(false))
|
|
|
|
|
{
|
|
|
|
|
using (var fs = _fileSystem.GetFileStream(destinationFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
|
|
|
|
|
{
|
|
|
|
|