Compare commits

...
33 changed files with 361 additions and 202 deletions
@@ -1,13 +1,14 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Api.Management.DependencyInjection;
using Umbraco.Cms.Api.Management.Security;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Extensions;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Infrastructure.DependencyInjection;
using Umbraco.Cms.Infrastructure.Examine.DependencyInjection;
using Umbraco.Cms.Web.Common.Hosting;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Extensions;
@@ -46,11 +47,12 @@ public static partial class UmbracoBuilderExtensions
{
var path = "~/";
IHostingEnvironment hostingEnvironment = factory.GetRequiredService<IHostingEnvironment>();
IHostEnvironment hostEnvironment = factory.GetRequiredService<IHostEnvironment>();
return new PhysicalFileSystem(
factory.GetRequiredService<IIOHelper>(),
hostingEnvironment,
hostEnvironment,
factory.GetRequiredService<ILogger<PhysicalFileSystem>>(),
hostingEnvironment.MapPathContentRoot(path),
hostEnvironment.MapPathContentRoot(path),
hostingEnvironment.ToAbsolute(path));
});
@@ -4,6 +4,7 @@
using System.Runtime.InteropServices;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
@@ -48,6 +49,7 @@ using Umbraco.Cms.Core.Telemetry;
using Umbraco.Cms.Core.Templates;
using Umbraco.Cms.Core.Web;
using Umbraco.Extensions;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Core.DependencyInjection
{
@@ -162,18 +164,19 @@ namespace Umbraco.Cms.Core.DependencyInjection
Services.AddUnique<IIOHelper>(factory =>
{
IHostingEnvironment hostingEnvironment = factory.GetRequiredService<IHostingEnvironment>();
IHostEnvironment hostEnvironment = factory.GetRequiredService<IHostEnvironment>();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return new IOHelperLinux(hostingEnvironment);
return new IOHelperLinux(hostingEnvironment, hostEnvironment);
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return new IOHelperOSX(hostingEnvironment);
return new IOHelperOSX(hostingEnvironment, hostEnvironment);
}
return new IOHelperWindows(hostingEnvironment);
return new IOHelperWindows(hostingEnvironment, hostEnvironment);
});
Services.AddUnique(factory => factory.GetRequiredService<AppCaches>().RuntimeCache);
@@ -183,7 +186,6 @@ namespace Umbraco.Cms.Core.DependencyInjection
Services.AddUnique<IEntryAssemblyMetadata, EntryAssemblyMetadata>();
this.AddAllCoreCollectionBuilders();
this.AddNotificationHandler<UmbracoApplicationStartingNotification, EssentialDirectoryCreator>();
Services.AddSingleton<UmbracoRequestPaths>();
+6 -5
View File
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using Umbraco.Cms.Core.Hosting;
using Microsoft.Extensions.Hosting;
using Umbraco.Cms.Core.Extensions;
namespace Umbraco.Cms.Core.Diagnostics;
@@ -37,7 +38,7 @@ public static class MiniDump
ValidTypeFlags = 0x0003ffff,
}
public static bool Dump(IMarchal marchal, IHostingEnvironment hostingEnvironment, Option options = Option.WithFullMemory, bool withException = false)
public static bool Dump(IMarchal marchal, IHostEnvironment hostEnvironment, Option options = Option.WithFullMemory, bool withException = false)
{
lock (LockO)
{
@@ -47,7 +48,7 @@ public static class MiniDump
// filter everywhere in our code = not!
var stacktrace = withException ? Environment.StackTrace : string.Empty;
var directory = hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.Data + "/MiniDump");
var directory = hostEnvironment.MapPathContentRoot(Constants.SystemDirectories.Data + "/MiniDump");
if (Directory.Exists(directory) == false)
{
@@ -127,11 +128,11 @@ public static class MiniDump
}
}
public static bool OkToDump(IHostingEnvironment hostingEnvironment)
public static bool OkToDump(IHostEnvironment hostEnvironment)
{
lock (LockO)
{
var directory = hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.Data + "/MiniDump");
var directory = hostEnvironment.MapPathContentRoot(Constants.SystemDirectories.Data + "/MiniDump");
if (Directory.Exists(directory) == false)
{
return true;
+17 -29
View File
@@ -1,8 +1,6 @@
using System.ComponentModel;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Core.IO
{
@@ -13,9 +11,8 @@ namespace Umbraco.Cms.Core.IO
{
private readonly ILogger<FileSystems> _logger;
private readonly ILoggerFactory _loggerFactory;
private readonly IIOHelper _ioHelper;
private GlobalSettings _globalSettings;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IFileSystemFactory _fileSystemFactory;
// wrappers for shadow support
@@ -38,27 +35,25 @@ namespace Umbraco.Cms.Core.IO
// DI wants a public ctor
public FileSystems(
ILoggerFactory loggerFactory,
IIOHelper ioHelper,
IOptions<GlobalSettings> globalSettings,
IHostingEnvironment hostingEnvironment)
IHostingEnvironment hostingEnvironment,
IFileSystemFactory fileSystemFactory)
{
_logger = loggerFactory.CreateLogger<FileSystems>();
_loggerFactory = loggerFactory;
_ioHelper = ioHelper;
_globalSettings = globalSettings.Value;
_hostingEnvironment = hostingEnvironment;
_fileSystemFactory = fileSystemFactory;
}
// Ctor for tests, allows you to set the various filesystems
internal FileSystems(
ILoggerFactory loggerFactory,
IIOHelper ioHelper,
IOptions<GlobalSettings> globalSettings,
IHostingEnvironment hostingEnvironment,
IFileSystem partialViewsFileSystem,
IFileSystem stylesheetFileSystem,
IFileSystem scriptsFileSystem,
IFileSystem mvcViewFileSystem) : this(loggerFactory, ioHelper, globalSettings, hostingEnvironment)
IFileSystem mvcViewFileSystem,
IFileSystemFactory fileSystemFactory)
: this(loggerFactory, hostingEnvironment, fileSystemFactory)
{
_partialViewsFileSystem = CreateShadowWrapperInternal(partialViewsFileSystem, "partials");
_stylesheetsFileSystem = CreateShadowWrapperInternal(stylesheetFileSystem, "css");
@@ -66,7 +61,6 @@ namespace Umbraco.Cms.Core.IO
_mvcViewsFileSystem = CreateShadowWrapperInternal(mvcViewFileSystem, "view");
// Set initialized to true so the filesystems doesn't get overwritten.
_wkfsInitialized = true;
}
/// <summary>
@@ -194,25 +188,19 @@ namespace Umbraco.Cms.Core.IO
{
ILogger<PhysicalFileSystem> logger = _loggerFactory.CreateLogger<PhysicalFileSystem>();
//TODO this is fucked, why do PhysicalFileSystem has a root url? Mvc views cannot be accessed by url!
var partialViewsFileSystem = new PhysicalFileSystem(_ioHelper, _hostingEnvironment, logger, _hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.PartialViews), _hostingEnvironment.ToAbsolute(Constants.SystemDirectories.PartialViews));
var scriptsFileSystem = new PhysicalFileSystem(_ioHelper, _hostingEnvironment, logger, _hostingEnvironment.MapPathWebRoot(_globalSettings.UmbracoScriptsPath), _hostingEnvironment.ToAbsolute(_globalSettings.UmbracoScriptsPath));
var mvcViewsFileSystem = new PhysicalFileSystem(_ioHelper, _hostingEnvironment, logger, _hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.MvcViews), _hostingEnvironment.ToAbsolute(Constants.SystemDirectories.MvcViews));
var partialViewsFileSystem = _fileSystemFactory.CreatePartialViewFileSystem();
var scriptsFileSystem = _fileSystemFactory.CreateScriptsFileSystem();
var mvcViewsFileSystem = _fileSystemFactory.CreateMvcViewsFileSystem();
_partialViewsFileSystem = new ShadowWrapper(partialViewsFileSystem, _ioHelper, _hostingEnvironment, _loggerFactory, "partials", IsScoped);
_scriptsFileSystem = new ShadowWrapper(scriptsFileSystem, _ioHelper, _hostingEnvironment, _loggerFactory, "scripts", IsScoped);
_mvcViewsFileSystem = new ShadowWrapper(mvcViewsFileSystem, _ioHelper, _hostingEnvironment, _loggerFactory, "views", IsScoped);
_partialViewsFileSystem = new ShadowWrapper(partialViewsFileSystem, _hostingEnvironment, _fileSystemFactory, "partials", IsScoped);
_scriptsFileSystem = new ShadowWrapper(scriptsFileSystem, _hostingEnvironment, _fileSystemFactory, "scripts", IsScoped);
_mvcViewsFileSystem = new ShadowWrapper(mvcViewsFileSystem, _hostingEnvironment, _fileSystemFactory, "views", IsScoped);
if (_stylesheetsFileSystem == null)
{
var stylesheetsFileSystem = new PhysicalFileSystem(
_ioHelper,
_hostingEnvironment,
logger,
_hostingEnvironment.MapPathWebRoot(_globalSettings.UmbracoCssPath),
_hostingEnvironment.ToAbsolute(_globalSettings.UmbracoCssPath));
var stylesheetsFileSystem = _fileSystemFactory.CreateStylesheetFileSystem();
_stylesheetsFileSystem = new ShadowWrapper(stylesheetsFileSystem, _ioHelper, _hostingEnvironment, _loggerFactory, "css", IsScoped);
_stylesheetsFileSystem = new ShadowWrapper(stylesheetsFileSystem, _hostingEnvironment, _fileSystemFactory, "css", IsScoped);
_shadowWrappers.Add(_stylesheetsFileSystem);
}
@@ -328,7 +316,7 @@ namespace Umbraco.Cms.Core.IO
{
lock (_shadowLocker)
{
var wrapper = new ShadowWrapper(filesystem, _ioHelper, _hostingEnvironment, _loggerFactory, shadowPath,() => IsScoped?.Invoke());
var wrapper = new ShadowWrapper(filesystem, _hostingEnvironment, _fileSystemFactory, shadowPath, () => IsScoped?.Invoke());
if (_shadowCurrentId != null)
{
wrapper.Shadow(_shadowCurrentId);
+18
View File
@@ -0,0 +1,18 @@
namespace Umbraco.Cms.Core.IO;
public interface IFileSystemFactory
{
IPhysicalFileSystem CreatePartialViewFileSystem();
IPhysicalFileSystem CreateScriptsFileSystem();
IPhysicalFileSystem CreateMvcViewsFileSystem();
IPhysicalFileSystem CreateStylesheetFileSystem();
IPhysicalFileSystem CreateMediaFileSystem();
IPhysicalFileSystem CreateFileSystem(string rootPath, string rootUrl);
}
+13 -4
View File
@@ -1,17 +1,26 @@
using System.Globalization;
using System.Reflection;
using Umbraco.Cms.Core.Hosting;
using Microsoft.Extensions.Hosting;
using Umbraco.Cms.Core.Extensions;
using Umbraco.Cms.Core.Strings;
using Umbraco.Extensions;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Core.IO;
public abstract class IOHelper : IIOHelper
{
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IHostEnvironment _hostEnvironment;
public IOHelper(IHostingEnvironment hostingEnvironment) => _hostingEnvironment =
hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
public IOHelper(
IHostingEnvironment hostingEnvironment,
IHostEnvironment hostEnvironment)
{
_hostingEnvironment =
hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
_hostEnvironment = hostEnvironment;
}
// static compiled regex for faster performance
// private static readonly Regex ResolveUrlPattern = new Regex("(=[\"\']?)(\\W?\\~(?:.(?![\"\']?\\s+(?:\\S+)=|[>\"\']))+.)[\"\']?", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
@@ -178,7 +187,7 @@ public abstract class IOHelper : IIOHelper
{
var tempFolderPaths = new[]
{
_hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.TempFileUploads),
_hostEnvironment.MapPathContentRoot(Constants.SystemDirectories.TempFileUploads),
};
foreach (var tempFolderPath in tempFolderPaths)
+6 -3
View File
@@ -1,11 +1,14 @@
using Umbraco.Cms.Core.Hosting;
using Microsoft.Extensions.Hosting;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Core.IO;
public class IOHelperLinux : IOHelper
{
public IOHelperLinux(IHostingEnvironment hostingEnvironment)
: base(hostingEnvironment)
public IOHelperLinux(
IHostingEnvironment hostingEnvironment,
IHostEnvironment hostEnvironment)
: base(hostingEnvironment, hostEnvironment)
{
}
+6 -3
View File
@@ -1,11 +1,14 @@
using Umbraco.Cms.Core.Hosting;
using Microsoft.Extensions.Hosting;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Core.IO;
public class IOHelperOSX : IOHelper
{
public IOHelperOSX(IHostingEnvironment hostingEnvironment)
: base(hostingEnvironment)
public IOHelperOSX(
IHostingEnvironment hostingEnvironment,
IHostEnvironment hostEnvironment)
: base(hostingEnvironment , hostEnvironment)
{
}
+6 -3
View File
@@ -1,11 +1,14 @@
using Umbraco.Cms.Core.Hosting;
using Microsoft.Extensions.Hosting;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Core.IO;
public class IOHelperWindows : IOHelper
{
public IOHelperWindows(IHostingEnvironment hostingEnvironment)
: base(hostingEnvironment)
public IOHelperWindows(
IHostingEnvironment hostingEnvironment,
IHostEnvironment hostEnvironment)
: base(hostingEnvironment, hostEnvironment)
{
}
+4 -3
View File
@@ -1,6 +1,7 @@
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Extensions;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.IO
@@ -26,7 +27,7 @@ namespace Umbraco.Cms.Core.IO
// eg "" or "/Views" or "/Media" or "/<vpath>/Media" in case of a virtual path
private readonly string _rootUrl;
public PhysicalFileSystem(IIOHelper ioHelper, IHostingEnvironment hostingEnvironment, ILogger<PhysicalFileSystem> logger, string rootPath, string rootUrl)
public PhysicalFileSystem(IIOHelper ioHelper, IHostEnvironment hostEnvironment, ILogger<PhysicalFileSystem> logger, string rootPath, string rootUrl)
{
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
@@ -60,7 +61,7 @@ namespace Umbraco.Cms.Core.IO
if (Path.IsPathRooted(rootPath) == false)
{
// but the test suite App.config cannot really "root" anything so we have to do it here
var localRoot = hostingEnvironment.MapPathContentRoot("~");
var localRoot = hostEnvironment.MapPathContentRoot("~");
rootPath = Path.Combine(localRoot, rootPath);
}
+4 -7
View File
@@ -1,5 +1,4 @@
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Extensions;
@@ -9,22 +8,20 @@ internal class ShadowWrapper : IFileSystem, IFileProviderFactory
{
private const string ShadowFsPath = "ShadowFs";
private readonly IIOHelper _ioHelper;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly ILoggerFactory _loggerFactory;
private readonly IFileSystemFactory _fileSystemFactory;
private readonly string _shadowPath;
private readonly Func<bool?>? _isScoped;
private string? _shadowDir;
private ShadowFileSystem? _shadowFileSystem;
public ShadowWrapper(IFileSystem innerFileSystem, IIOHelper ioHelper, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory, string shadowPath, Func<bool?>? isScoped = null)
public ShadowWrapper(IFileSystem innerFileSystem, IHostingEnvironment hostingEnvironment, IFileSystemFactory fileSystemFactory, string shadowPath, Func<bool?>? isScoped = null)
{
InnerFileSystem = innerFileSystem;
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
_hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
_loggerFactory = loggerFactory;
_fileSystemFactory = fileSystemFactory;
_shadowPath = shadowPath;
_isScoped = isScoped;
}
@@ -132,7 +129,7 @@ internal class ShadowWrapper : IFileSystem, IFileProviderFactory
var rootUrl = Path.Combine(ShadowFsPath, id, _shadowPath);
_shadowDir = Path.Combine(_hostingEnvironment.LocalTempPath, rootUrl);
Directory.CreateDirectory(_shadowDir);
var tempfs = new PhysicalFileSystem(_ioHelper, _hostingEnvironment, _loggerFactory.CreateLogger<PhysicalFileSystem>(), _shadowDir, rootUrl);
var tempfs = _fileSystemFactory.CreateFileSystem(_shadowDir, rootUrl);
_shadowFileSystem = new ShadowFileSystem(InnerFileSystem, tempfs);
}
@@ -1,32 +0,0 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Notifications;
namespace Umbraco.Cms.Core.Runtime;
public class EssentialDirectoryCreator : INotificationHandler<UmbracoApplicationStartingNotification>
{
private readonly GlobalSettings _globalSettings;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IIOHelper _ioHelper;
public EssentialDirectoryCreator(IIOHelper ioHelper, IHostingEnvironment hostingEnvironment, IOptions<GlobalSettings> globalSettings)
{
_ioHelper = ioHelper;
_hostingEnvironment = hostingEnvironment;
_globalSettings = globalSettings.Value;
}
public void Handle(UmbracoApplicationStartingNotification notification)
{
// ensure we have some essential directories
// every other component can then initialize safely
_ioHelper.EnsurePathExists(_hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.Data));
_ioHelper.EnsurePathExists(_hostingEnvironment.MapPathWebRoot(_globalSettings.UmbracoMediaPhysicalRootPath));
_ioHelper.EnsurePathExists(_hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.MvcViews));
_ioHelper.EnsurePathExists(_hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.PartialViews));
}
}
@@ -44,16 +44,8 @@ public static partial class UmbracoBuilderExtensions
builder.SetMediaFileSystem(factory =>
{
IIOHelper ioHelper = factory.GetRequiredService<IIOHelper>();
IHostingEnvironment hostingEnvironment = factory.GetRequiredService<IHostingEnvironment>();
ILogger<PhysicalFileSystem> logger = factory.GetRequiredService<ILogger<PhysicalFileSystem>>();
GlobalSettings globalSettings = factory.GetRequiredService<IOptions<GlobalSettings>>().Value;
var rootPath = Path.IsPathRooted(globalSettings.UmbracoMediaPhysicalRootPath)
? globalSettings.UmbracoMediaPhysicalRootPath
: hostingEnvironment.MapPathWebRoot(globalSettings.UmbracoMediaPhysicalRootPath);
var rootUrl = hostingEnvironment.ToAbsolute(globalSettings.UmbracoMediaPath);
return new PhysicalFileSystem(ioHelper, hostingEnvironment, logger, rootPath, rootUrl);
IFileSystemFactory fileSystemFactory = factory.GetRequiredService<IFileSystemFactory>();
return fileSystemFactory.CreateMediaFileSystem();
});
return builder;
@@ -1,10 +1,10 @@
using System.Reflection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Serilog.Core;
using Serilog.Events;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Diagnostics;
using Umbraco.Cms.Core.Hosting;
namespace Umbraco.Cms.Core.Logging.Serilog.Enrichers;
@@ -13,17 +13,18 @@ namespace Umbraco.Cms.Core.Logging.Serilog.Enrichers;
/// </summary>
public class ThreadAbortExceptionEnricher : ILogEventEnricher
{
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IMarchal _marchal;
private readonly IHostEnvironment _hostEnvironment;
private CoreDebugSettings _coreDebugSettings;
public ThreadAbortExceptionEnricher(
IOptionsMonitor<CoreDebugSettings> coreDebugSettings,
IHostingEnvironment hostingEnvironment, IMarchal marchal)
IHostEnvironment hostEnvironment,
IMarchal marchal)
{
_coreDebugSettings = coreDebugSettings.CurrentValue;
_hostingEnvironment = hostingEnvironment;
_marchal = marchal;
_hostEnvironment = hostEnvironment;
coreDebugSettings.OnChange(x => _coreDebugSettings = x);
}
@@ -79,7 +80,7 @@ public class ThreadAbortExceptionEnricher : ILogEventEnricher
IsMonitorEnterThreadAbortException(logEvent.Exception!);
// dump if it is ok to dump (might have a cap on number of dump...)
dump &= MiniDump.OkToDump(_hostingEnvironment);
dump &= MiniDump.OkToDump(_hostEnvironment);
if (!dump)
{
@@ -90,7 +91,7 @@ public class ThreadAbortExceptionEnricher : ILogEventEnricher
{
try
{
var dumped = MiniDump.Dump(_marchal, _hostingEnvironment, withException: true);
var dumped = MiniDump.Dump(_marchal, _hostEnvironment, withException: true);
message += dumped
? ". A minidump was created in App_Data/MiniDump."
: ". Failed to create a minidump.";
@@ -50,6 +50,7 @@ using Umbraco.Cms.Web.Common.Configuration;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Cms.Web.Common.DependencyInjection;
using Umbraco.Cms.Web.Common.FileProviders;
using Umbraco.Cms.Web.Common.FileSystem;
using Umbraco.Cms.Web.Common.Helpers;
using Umbraco.Cms.Web.Common.Localization;
using Umbraco.Cms.Web.Common.Middleware;
@@ -58,6 +59,7 @@ using Umbraco.Cms.Web.Common.Mvc;
using Umbraco.Cms.Web.Common.Preview;
using Umbraco.Cms.Web.Common.Profiler;
using Umbraco.Cms.Web.Common.Repositories;
using Umbraco.Cms.Web.Common.Runtime;
using Umbraco.Cms.Web.Common.Security;
using Umbraco.Cms.Web.Common.Templates;
using Umbraco.Cms.Web.Common.UmbracoContext;
@@ -169,6 +171,9 @@ public static partial class UmbracoBuilderExtensions
builder.Services.AddTransient<IIpAddressUtilities, IpAddressUtilities>();
builder.Services.AddUnique<IPreviewTokenGenerator, UserBasedPreviewTokenGenerator>();
builder.Services.AddSingleton<IFileSystemFactory, FileSystemFactory>();
builder.AddNotificationHandler<UmbracoApplicationStartingNotification, EssentialDirectoryCreator>();
return builder;
}
@@ -0,0 +1,86 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Extensions;
using Umbraco.Cms.Core.IO;
using Umbraco.Extensions;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Web.Common.FileSystem;
public class FileSystemFactory : IFileSystemFactory
{
private readonly IIOHelper _ioHelper;
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IHostEnvironment _hostEnvironment;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly ILogger<PhysicalFileSystem> _fileSystemLogger;
private readonly GlobalSettings _globalSettings;
public FileSystemFactory(
IIOHelper ioHelper,
IWebHostEnvironment webHostEnvironment,
IHostEnvironment hostEnvironment,
IHostingEnvironment hostingEnvironment,
ILoggerFactory loggerFactory,
IOptions<GlobalSettings> globalSettings)
{
_ioHelper = ioHelper;
_webHostEnvironment = webHostEnvironment;
_hostEnvironment = hostEnvironment;
_hostingEnvironment = hostingEnvironment;
_fileSystemLogger = loggerFactory.CreateLogger<PhysicalFileSystem>();
_globalSettings = globalSettings.Value;
}
public IPhysicalFileSystem CreatePartialViewFileSystem() =>
new PhysicalFileSystem(
_ioHelper,
_hostEnvironment,
_fileSystemLogger,
_hostEnvironment.MapPathContentRoot(Core.Constants.SystemDirectories.PartialViews),
_hostingEnvironment.ToAbsolute(Core.Constants.SystemDirectories.PartialViews));
public IPhysicalFileSystem CreateScriptsFileSystem() =>
new PhysicalFileSystem(
_ioHelper,
_hostEnvironment,
_fileSystemLogger,
_webHostEnvironment.MapPathWebRoot(_globalSettings.UmbracoScriptsPath),
_hostingEnvironment.ToAbsolute(_globalSettings.UmbracoScriptsPath));
//TODO this is fucked, why do PhysicalFileSystem has a root url? Mvc views cannot be accessed by url! (Comment moved from FileSystems.cs)
public IPhysicalFileSystem CreateMvcViewsFileSystem() =>
new PhysicalFileSystem(
_ioHelper,
_hostEnvironment,
_fileSystemLogger,
_hostEnvironment.MapPathContentRoot(Core.Constants.SystemDirectories.MvcViews),
_hostingEnvironment.ToAbsolute(Core.Constants.SystemDirectories.MvcViews));
public IPhysicalFileSystem CreateStylesheetFileSystem() =>
new PhysicalFileSystem(
_ioHelper,
_hostEnvironment,
_fileSystemLogger,
_webHostEnvironment.MapPathWebRoot(_globalSettings.UmbracoCssPath),
_hostingEnvironment.ToAbsolute(_globalSettings.UmbracoCssPath));
public IPhysicalFileSystem CreateMediaFileSystem()
{
var rootPath = Path.IsPathRooted(_globalSettings.UmbracoMediaPhysicalRootPath)
? _globalSettings.UmbracoMediaPhysicalRootPath
: _webHostEnvironment.MapPathWebRoot(_globalSettings.UmbracoMediaPhysicalRootPath);
return new PhysicalFileSystem(
_ioHelper,
_hostEnvironment,
_fileSystemLogger,
rootPath,
_hostingEnvironment.ToAbsolute(_globalSettings.UmbracoMediaPath));
}
public IPhysicalFileSystem CreateFileSystem(string rootPath, string rootUrl) =>
new PhysicalFileSystem(_ioHelper, _hostEnvironment, _fileSystemLogger, rootPath, rootUrl);
}
@@ -0,0 +1,41 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Extensions;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Extensions;
namespace Umbraco.Cms.Web.Common.Runtime;
public class EssentialDirectoryCreator : INotificationHandler<UmbracoApplicationStartingNotification>
{
private readonly GlobalSettings _globalSettings;
private readonly IHostEnvironment _hostEnvironment;
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IIOHelper _ioHelper;
public EssentialDirectoryCreator(
IIOHelper ioHelper,
IHostEnvironment hostEnvironment,
IWebHostEnvironment webHostEnvironment,
IOptions<GlobalSettings> globalSettings)
{
_ioHelper = ioHelper;
_hostEnvironment = hostEnvironment;
_webHostEnvironment = webHostEnvironment;
_globalSettings = globalSettings.Value;
}
public void Handle(UmbracoApplicationStartingNotification notification)
{
// ensure we have some essential directories
// every other component can then initialize safely
_ioHelper.EnsurePathExists(_hostEnvironment.MapPathContentRoot(Core.Constants.SystemDirectories.Data));
_ioHelper.EnsurePathExists(_webHostEnvironment.MapPathWebRoot(_globalSettings.UmbracoMediaPhysicalRootPath));
_ioHelper.EnsurePathExists(_hostEnvironment.MapPathContentRoot(Core.Constants.SystemDirectories.MvcViews));
_ioHelper.EnsurePathExists(_hostEnvironment.MapPathContentRoot(Core.Constants.SystemDirectories.PartialViews));
}
}
+10 -9
View File
@@ -1,13 +1,11 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
using System;
using System.IO;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Moq;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Cache;
@@ -32,6 +30,7 @@ using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Cms.Infrastructure.Serialization;
using Umbraco.Cms.Tests.Common.TestHelpers;
using Umbraco.Extensions;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Tests.Common;
@@ -88,9 +87,8 @@ public abstract class TestHelperBase
var loggerFactory = NullLoggerFactory.Instance;
var fileSystems = new FileSystems(
loggerFactory,
Mock.Of<IIOHelper>(),
Mock.Of<IOptions<GlobalSettings>>(),
Mock.Of<IHostingEnvironment>());
Mock.Of<IHostingEnvironment>(),
Mock.Of<IFileSystemFactory>());
var mediaFileManager = new MediaFileManager(
Mock.Of<IFileSystem>(),
Mock.Of<IMediaPathScheme>(),
@@ -153,18 +151,19 @@ public abstract class TestHelperBase
if (_ioHelper == null)
{
var hostingEnvironment = GetHostingEnvironment();
var hostEnvironment = GetHostEnvironment();
if (TestEnvironment.IsWindows)
{
_ioHelper = new IOHelperWindows(hostingEnvironment);
_ioHelper = new IOHelperWindows(hostingEnvironment, hostEnvironment);
}
else if (TestEnvironment.IsLinux)
{
_ioHelper = new IOHelperLinux(hostingEnvironment);
_ioHelper = new IOHelperLinux(hostingEnvironment, hostEnvironment);
}
else if (TestEnvironment.IsOSX)
{
_ioHelper = new IOHelperOSX(hostingEnvironment);
_ioHelper = new IOHelperOSX(hostingEnvironment, hostEnvironment);
}
else
{
@@ -220,6 +219,8 @@ public abstract class TestHelperBase
public abstract IHostingEnvironment GetHostingEnvironment();
public abstract IHostEnvironment GetHostEnvironment();
public abstract IApplicationShutdownRegistry GetHostingEnvironmentLifetime();
public abstract IIpResolver GetIpResolver();
@@ -19,15 +19,15 @@ public static class FileSystemsCreator
/// <param name="stylesheetFileSystem"></param>
/// <param name="scriptsFileSystem"></param>
/// <param name="mvcViewFileSystem"></param>
/// <param name="fileSystemFactory"></param>
/// <returns></returns>
public static FileSystems CreateTestFileSystems(
ILoggerFactory loggerFactory,
IIOHelper ioHelper,
IOptions<GlobalSettings> globalSettings,
IHostingEnvironment hostingEnvironment,
IFileSystem partialViewsFileSystem,
IFileSystem stylesheetFileSystem,
IFileSystem scriptsFileSystem,
IFileSystem mvcViewFileSystem) =>
new(loggerFactory, ioHelper, globalSettings, hostingEnvironment, partialViewsFileSystem, stylesheetFileSystem, scriptsFileSystem, mvcViewFileSystem);
IFileSystem mvcViewFileSystem,
IFileSystemFactory fileSystemFactory) =>
new(loggerFactory, hostingEnvironment, partialViewsFileSystem, stylesheetFileSystem, scriptsFileSystem, mvcViewFileSystem, fileSystemFactory);
}
@@ -0,0 +1,18 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
namespace Umbraco.Cms.Tests.Common.Testing;
public class TestHostEnvironment : IHostEnvironment
{
public string ApplicationName { get; set; }
public IFileProvider ContentRootFileProvider { get; set; }
public string ContentRootPath { get; set; }
public string EnvironmentName { get; set; }
}
@@ -110,6 +110,8 @@ public class TestHelper : TestHelperBase
GetIOptionsMonitorOfWebRoutingSettings(),
_hostEnvironment);
public override IHostEnvironment GetHostEnvironment() => new TestHostEnvironment();
private IOptionsMonitor<HostingSettings> GetIOptionsMonitorOfHostingSettings()
{
var hostingSettings = new HostingSettings();
@@ -1,19 +1,20 @@
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Tests.Common.Attributes;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Implementations;
using Umbraco.Cms.Tests.Integration.Testing;
using Umbraco.Extensions;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.IO;
@@ -32,7 +33,9 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
// SetUp does not start before the previous TearDown returns
private IHostingEnvironment HostingEnvironment => GetRequiredService<IHostingEnvironment>();
private IHostEnvironment HostEnvironment => GetRequiredService<IHostEnvironment>();
private ILogger<PhysicalFileSystem> Logger => GetRequiredService<ILogger<PhysicalFileSystem>>();
private IFileSystemFactory FileSystemFactory => GetRequiredService<IFileSystemFactory>();
private void ClearFiles(IHostingEnvironment hostingEnvironment)
{
@@ -52,8 +55,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
Directory.CreateDirectory(path + "/ShadowTests/d1");
@@ -86,8 +89,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
Directory.CreateDirectory(path + "/ShadowTests/sub");
@@ -135,8 +138,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
File.WriteAllText(path + "/ShadowTests/f1.txt", "foo");
@@ -175,8 +178,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
Directory.CreateDirectory(path + "/ShadowTests/sub");
@@ -230,8 +233,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
Assert.Throws<UnauthorizedAccessException>(() =>
@@ -251,8 +254,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
File.WriteAllText(path + "/ShadowTests/f2.txt", "foo");
@@ -294,8 +297,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo")))
@@ -338,8 +341,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo")))
@@ -362,8 +365,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
Directory.CreateDirectory(path + "/ShadowTests/sub/sub");
@@ -399,11 +402,11 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
var scopedFileSystems = false;
var phy = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path, "ignore");
var phy = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path, "ignore");
var globalSettings = Options.Create(new GlobalSettings());
var fileSystems =
new FileSystems(loggerFactory, IOHelper, globalSettings, HostingEnvironment)
new FileSystems(loggerFactory, HostingEnvironment, FileSystemFactory)
{
IsScoped = () => scopedFileSystems
};
@@ -515,11 +518,11 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
var scopedFileSystems = false;
var phy = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path, "ignore");
var phy = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path, "ignore");
var globalSettings = Options.Create(new GlobalSettings());
var fileSystems =
new FileSystems(NullLoggerFactory.Instance, IOHelper, globalSettings, HostingEnvironment)
new FileSystems(NullLoggerFactory.Instance, HostingEnvironment, FileSystemFactory)
{
IsScoped = () => scopedFileSystems
};
@@ -584,11 +587,11 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
var scopedFileSystems = false;
var phy = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path, "ignore");
var phy = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path, "ignore");
var globalSettings = Options.Create(new GlobalSettings());
var fileSystems =
new FileSystems(NullLoggerFactory.Instance, IOHelper, globalSettings, HostingEnvironment)
new FileSystems(NullLoggerFactory.Instance, HostingEnvironment, FileSystemFactory)
{
IsScoped = () => scopedFileSystems
};
@@ -710,8 +713,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
// Act
@@ -744,8 +747,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
// Act
@@ -778,8 +781,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
// Act
@@ -812,8 +815,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
// Act
@@ -852,8 +855,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
// Act
@@ -907,8 +910,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
// Act
@@ -943,8 +946,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "ignore");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "ignore");
var ss = new ShadowFileSystem(fs, sfs);
// Act
@@ -984,8 +987,8 @@ internal sealed class ShadowFileSystemTests : UmbracoIntegrationTest
Directory.CreateDirectory(path + "/ShadowTests");
Directory.CreateDirectory(path + "/ShadowSystem");
var fs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowTests/", "rootUrl");
var sfs = new PhysicalFileSystem(IOHelper, HostingEnvironment, Logger, path + "/ShadowSystem/", "rootUrl");
var fs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowTests/", "rootUrl");
var sfs = new PhysicalFileSystem(IOHelper, HostEnvironment, Logger, path + "/ShadowSystem/", "rootUrl");
var ss = new ShadowFileSystem(fs, sfs);
// Act
@@ -1,18 +1,19 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
using Umbraco.Cms.Tests.Common.TestHelpers;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories;
@@ -24,7 +25,7 @@ internal sealed class PartialViewRepositoryTests : UmbracoIntegrationTest
public void SetUp() =>
_fileSystem = new PhysicalFileSystem(
IOHelper,
HostingEnvironment,
HostEnvironment,
LoggerFactory.CreateLogger<PhysicalFileSystem>(),
HostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.PartialViews),
HostingEnvironment.ToAbsolute(Constants.SystemDirectories.PartialViews));
@@ -38,6 +39,7 @@ internal sealed class PartialViewRepositoryTests : UmbracoIntegrationTest
}
private IHostingEnvironment HostingEnvironment => GetRequiredService<IHostingEnvironment>();
private IHostEnvironment HostEnvironment => GetRequiredService<IHostEnvironment>();
private IFileSystem _fileSystem;
@@ -47,13 +49,12 @@ internal sealed class PartialViewRepositoryTests : UmbracoIntegrationTest
// unless noted otherwise, no changes / 7.2.8
var fileSystems = FileSystemsCreator.CreateTestFileSystems(
LoggerFactory,
IOHelper,
GetRequiredService<IOptions<GlobalSettings>>(),
HostingEnvironment,
_fileSystem,
null,
null,
null);
null,
GetRequiredService<IFileSystemFactory>());
var provider = ScopeProvider;
using (var scope = provider.CreateScope())
@@ -4,11 +4,11 @@
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NUnit.Framework;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Repositories;
@@ -16,6 +16,7 @@ using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
using Umbraco.Cms.Tests.Common.TestHelpers;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories;
@@ -27,17 +28,16 @@ internal sealed class ScriptRepositoryTest : UmbracoIntegrationTest
public void SetUpFileSystem()
{
var path = GlobalSettings.UmbracoScriptsPath;
_fileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, LoggerFactory.CreateLogger<PhysicalFileSystem>(), HostingEnvironment.MapPathWebRoot(path), HostingEnvironment.ToAbsolute(path));
_fileSystem = new PhysicalFileSystem(IOHelper, HostEnvironment, LoggerFactory.CreateLogger<PhysicalFileSystem>(), HostingEnvironment.MapPathWebRoot(path), HostingEnvironment.ToAbsolute(path));
_fileSystems = FileSystemsCreator.CreateTestFileSystems(
LoggerFactory,
IOHelper,
GetRequiredService<IOptions<GlobalSettings>>(),
HostingEnvironment,
null,
null,
_fileSystem,
null);
null,
GetRequiredService<IFileSystemFactory>());
using (var stream = CreateStream("Umbraco.Sys.registerNamespace(\"Umbraco.Utils\");"))
{
_fileSystem.AddFile("test-script.js", stream);
@@ -53,6 +53,7 @@ internal sealed class ScriptRepositoryTest : UmbracoIntegrationTest
}
private IHostingEnvironment HostingEnvironment => GetRequiredService<IHostingEnvironment>();
private IHostEnvironment HostEnvironment => GetRequiredService<IHostEnvironment>();
private FileSystems _fileSystems;
private IFileSystem _fileSystem;
@@ -5,11 +5,11 @@ using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NUnit.Framework;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Repositories;
@@ -17,6 +17,7 @@ using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
using Umbraco.Cms.Tests.Common.TestHelpers;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories;
@@ -28,17 +29,16 @@ internal sealed class StylesheetRepositoryTest : UmbracoIntegrationTest
public void SetUpFileSystem()
{
var path = HostingEnvironment.MapPathWebRoot(GlobalSettings.UmbracoCssPath);
_fileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), path, "/css");
_fileSystem = new PhysicalFileSystem(IOHelper, HostEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), path, "/css");
_fileSystems = FileSystemsCreator.CreateTestFileSystems(
LoggerFactory,
IOHelper,
GetRequiredService<IOptions<GlobalSettings>>(),
HostingEnvironment,
null,
_fileSystem,
null,
null);
null,
GetRequiredService<IFileSystemFactory>());
var stream = CreateStream("body {background:#EE7600; color:#FFF;}");
_fileSystem.AddFile("styles.css", stream);
@@ -56,6 +56,7 @@ internal sealed class StylesheetRepositoryTest : UmbracoIntegrationTest
private IFileSystem _fileSystem;
private IHostingEnvironment HostingEnvironment => GetRequiredService<IHostingEnvironment>();
private IHostEnvironment HostEnvironment => GetRequiredService<IHostEnvironment>();
private IStylesheetRepository CreateRepository()
{
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;
@@ -13,7 +14,6 @@ using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Repositories;
@@ -27,6 +27,7 @@ using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Implementations;
using Umbraco.Cms.Tests.Integration.Testing;
using Umbraco.Extensions;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories;
@@ -42,7 +43,7 @@ internal sealed class TemplateRepositoryTest : UmbracoIntegrationTest
// Delete all files
var fsViews = new PhysicalFileSystem(
IOHelper,
HostingEnvironment,
HostEnvironment,
LoggerFactory.CreateLogger<PhysicalFileSystem>(),
HostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.MvcViews),
HostingEnvironment.ToAbsolute(Constants.SystemDirectories.MvcViews));
@@ -54,6 +55,7 @@ internal sealed class TemplateRepositoryTest : UmbracoIntegrationTest
}
private IHostingEnvironment HostingEnvironment => GetRequiredService<IHostingEnvironment>();
private IHostEnvironment HostEnvironment => GetRequiredService<IHostEnvironment>();
private FileSystems FileSystems => GetRequiredService<FileSystems>();
@@ -4,17 +4,18 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Moq;
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Cms.Tests.Common;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
using Umbraco.Extensions;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Scoping;
@@ -31,6 +32,7 @@ internal sealed class ScopeFileSystemsTests : UmbracoIntegrationTest
private MediaFileManager MediaFileManager => GetRequiredService<MediaFileManager>();
private IHostingEnvironment HostingEnvironment => GetRequiredService<IHostingEnvironment>();
private IHostEnvironment HostEnvironment => GetRequiredService<IHostEnvironment>();
private void ClearFiles(IIOHelper ioHelper)
{
@@ -45,7 +47,7 @@ internal sealed class ScopeFileSystemsTests : UmbracoIntegrationTest
{
var rootPath = HostingEnvironment.MapPathWebRoot(GlobalSettings.UmbracoMediaPhysicalRootPath);
var rootUrl = HostingEnvironment.ToAbsolute(GlobalSettings.UmbracoMediaPath);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var mediaFileManager = MediaFileManager;
Assert.IsFalse(physMediaFileSystem.FileExists("f1.txt"));
@@ -74,7 +76,7 @@ internal sealed class ScopeFileSystemsTests : UmbracoIntegrationTest
{
var rootPath = HostingEnvironment.MapPathWebRoot(GlobalSettings.UmbracoMediaPhysicalRootPath);
var rootUrl = HostingEnvironment.ToAbsolute(GlobalSettings.UmbracoMediaPath);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var mediaFileManager = MediaFileManager;
Assert.IsFalse(physMediaFileSystem.FileExists("f1.txt"));
@@ -105,7 +107,7 @@ internal sealed class ScopeFileSystemsTests : UmbracoIntegrationTest
{
var rootPath = HostingEnvironment.MapPathWebRoot(GlobalSettings.UmbracoMediaPhysicalRootPath);
var rootUrl = HostingEnvironment.ToAbsolute(GlobalSettings.UmbracoMediaPath);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var mediaFileManager = MediaFileManager;
var taskHelper = new TaskHelper(Mock.Of<ILogger<TaskHelper>>());
@@ -1,14 +1,15 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Moq;
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Persistence.EFCore.Scoping;
using Umbraco.Cms.Tests.Common;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
using Umbraco.Cms.Tests.Integration.Umbraco.Persistence.EFCore.DbContext;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Persistence.EFCore.Scoping;
@@ -25,6 +26,7 @@ internal sealed class EFCoreScopedFileSystemsTests : UmbracoIntegrationTest
private MediaFileManager MediaFileManager => GetRequiredService<MediaFileManager>();
private IHostingEnvironment HostingEnvironment => GetRequiredService<IHostingEnvironment>();
private IHostEnvironment HostEnvironment => GetRequiredService<IHostEnvironment>();
private IEFCoreScopeProvider<TestUmbracoDbContext> EfCoreScopeProvider => GetRequiredService<IEFCoreScopeProvider<TestUmbracoDbContext>>();
private IEFCoreScopeAccessor<TestUmbracoDbContext> EfCoreScopeAccessor => GetRequiredService<IEFCoreScopeAccessor<TestUmbracoDbContext>>();
@@ -41,7 +43,7 @@ internal sealed class EFCoreScopedFileSystemsTests : UmbracoIntegrationTest
{
var rootPath = HostingEnvironment.MapPathWebRoot(GlobalSettings.UmbracoMediaPhysicalRootPath);
var rootUrl = HostingEnvironment.ToAbsolute(GlobalSettings.UmbracoMediaPath);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var mediaFileManager = MediaFileManager;
Assert.IsFalse(physMediaFileSystem.FileExists("f1.txt"));
@@ -67,7 +69,7 @@ internal sealed class EFCoreScopedFileSystemsTests : UmbracoIntegrationTest
{
var rootPath = HostingEnvironment.MapPathWebRoot(GlobalSettings.UmbracoMediaPhysicalRootPath);
var rootUrl = HostingEnvironment.ToAbsolute(GlobalSettings.UmbracoMediaPath);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var mediaFileManager = MediaFileManager;
Assert.IsFalse(physMediaFileSystem.FileExists("f1.txt"));
@@ -98,7 +100,7 @@ internal sealed class EFCoreScopedFileSystemsTests : UmbracoIntegrationTest
{
var rootPath = HostingEnvironment.MapPathWebRoot(GlobalSettings.UmbracoMediaPhysicalRootPath);
var rootUrl = HostingEnvironment.ToAbsolute(GlobalSettings.UmbracoMediaPath);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var physMediaFileSystem = new PhysicalFileSystem(IOHelper, HostEnvironment, GetRequiredService<ILogger<PhysicalFileSystem>>(), rootPath, rootUrl);
var mediaFileManager = MediaFileManager;
var taskHelper = new TaskHelper(Mock.Of<ILogger<TaskHelper>>());
@@ -9,6 +9,7 @@ using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Moq;
@@ -310,6 +311,8 @@ public static class TestHelper
public static IHostingEnvironment GetHostingEnvironment() => s_testHelperInternal.GetHostingEnvironment();
public static IHostEnvironment GetHostEnvironment() => s_testHelperInternal.GetHostEnvironment();
public static ILoggingConfiguration GetLoggingConfiguration(IHostingEnvironment hostingEnv) =>
s_testHelperInternal.GetLoggingConfiguration(hostingEnv);
@@ -345,6 +348,12 @@ public static class TestHelper
x.ContentRootPath == testPath));
}
public override IHostEnvironment GetHostEnvironment()
{
var testPath = TestContext.CurrentContext.TestDirectory.Split("bin")[0];
return new TestHostEnvironment { ContentRootPath = testPath };
}
public override IApplicationShutdownRegistry GetHostingEnvironmentLifetime()
=> Mock.Of<IApplicationShutdownRegistry>();
@@ -67,9 +67,8 @@ public class ComponentTests
var fs = new FileSystems(
loggerFactory,
IOHelper,
Options.Create(globalSettings),
Mock.Of<IHostingEnvironment>());
Mock.Of<IHostingEnvironment>(),
Mock.Of<IFileSystemFactory>());
var coreDebug = new CoreDebugSettings();
var mediaFileManager = new MediaFileManager(
Mock.Of<IFileSystem>(),
@@ -40,7 +40,7 @@ public class PhysicalFileSystemTests : AbstractFileSystemTests
public PhysicalFileSystemTests()
: base(new PhysicalFileSystem(
TestHelper.IOHelper,
TestHelper.GetHostingEnvironment(),
TestHelper.GetHostEnvironment(),
Mock.Of<ILogger<PhysicalFileSystem>>(),
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileSysTests"),
"/Media/"))
@@ -75,9 +75,8 @@ public class ScopedNotificationPublisherTests
var fileSystems = new FileSystems(
loggerFactory,
Mock.Of<IIOHelper>(),
Options.Create(new GlobalSettings()),
Mock.Of<IHostingEnvironment>());
Mock.Of<IHostingEnvironment>(),
Mock.Of<IFileSystemFactory>());
var mediaFileManager = new MediaFileManager(
Mock.Of<IFileSystem>(),
@@ -31,9 +31,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.Scoping
var loggerFactory = NullLoggerFactory.Instance;
var fileSystems = new FileSystems(
loggerFactory,
Mock.Of<IIOHelper>(),
Mock.Of<IOptions<GlobalSettings>>(),
Mock.Of<IHostingEnvironment>());
Mock.Of<IHostingEnvironment>(),
Mock.Of<IFileSystemFactory>());
var mediaFileManager = new MediaFileManager(
Mock.Of<IFileSystem>(),
Mock.Of<IMediaPathScheme>(),