Files
Umbraco-CMS/src/Umbraco.Core/Runtime/EssentialDirectoryCreator.cs

35 lines
1.5 KiB
C#
Raw Normal View History

2020-12-15 15:20:36 +00:00
using Microsoft.Extensions.Options;
using Umbraco.Core.Configuration.Models;
2020-12-15 15:20:36 +00:00
using Umbraco.Core.Events;
2020-11-19 06:37:31 -08:00
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
namespace Umbraco.Core.Runtime
{
2020-12-15 15:20:36 +00:00
public class EssentialDirectoryCreator : INotificationHandler<UmbracoApplicationStarting>
{
2019-11-13 21:00:54 +01:00
private readonly IIOHelper _ioHelper;
2020-11-19 06:37:31 -08:00
private readonly IHostingEnvironment _hostingEnvironment;
private readonly GlobalSettings _globalSettings;
2019-11-13 21:00:54 +01:00
2020-12-15 15:20:36 +00:00
public EssentialDirectoryCreator(IIOHelper ioHelper, IHostingEnvironment hostingEnvironment, IOptions<GlobalSettings> globalSettings)
2019-11-13 21:00:54 +01:00
{
_ioHelper = ioHelper;
2020-11-19 06:37:31 -08:00
_hostingEnvironment = hostingEnvironment;
_globalSettings = globalSettings.Value;
2019-11-13 21:00:54 +01:00
}
public void Handle(UmbracoApplicationStarting notification)
{
2016-09-08 18:43:58 +02:00
// ensure we have some essential directories
// every other component can then initialize safely
2020-11-19 06:37:31 -08:00
_ioHelper.EnsurePathExists(_hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.Data));
_ioHelper.EnsurePathExists(_hostingEnvironment.MapPathWebRoot(_globalSettings.UmbracoMediaPath));
_ioHelper.EnsurePathExists(_hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.MvcViews));
_ioHelper.EnsurePathExists(_hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.PartialViews));
_ioHelper.EnsurePathExists(_hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.MacroPartials));
2019-01-07 09:30:47 +01:00
2020-12-15 15:20:36 +00:00
}
}
}