2020-12-15 15:20:36 +00:00
|
|
|
using Microsoft.Extensions.Options;
|
2020-08-21 14:52:47 +01:00
|
|
|
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;
|
2016-09-01 11:25:00 +02:00
|
|
|
using Umbraco.Core.IO;
|
|
|
|
|
|
2020-12-24 11:46:17 +11:00
|
|
|
namespace Umbraco.Core.Runtime
|
2016-09-01 11:25:00 +02:00
|
|
|
{
|
2020-12-15 15:20:36 +00:00
|
|
|
public class EssentialDirectoryCreator : INotificationHandler<UmbracoApplicationStarting>
|
2016-09-01 11:25:00 +02:00
|
|
|
{
|
2019-11-13 21:00:54 +01:00
|
|
|
private readonly IIOHelper _ioHelper;
|
2020-11-19 06:37:31 -08:00
|
|
|
private readonly IHostingEnvironment _hostingEnvironment;
|
2020-08-21 14:52:47 +01:00
|
|
|
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;
|
2020-08-21 14:52:47 +01:00
|
|
|
_globalSettings = globalSettings.Value;
|
2019-11-13 21:00:54 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-19 09:57:55 +01:00
|
|
|
public void Handle(UmbracoApplicationStarting notification)
|
2016-09-01 11:25:00 +02:00
|
|
|
{
|
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
|
|
|
}
|
2016-09-01 11:25:00 +02:00
|
|
|
}
|
|
|
|
|
}
|