Changed SystemDirectories from static to instance, Added interface in abstractions and create a static property on current.
This commit is contained in:
33
src/Umbraco.Abstractions/IO/ISystemDirectories.cs
Normal file
33
src/Umbraco.Abstractions/IO/ISystemDirectories.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace Umbraco.Core.IO
|
||||
{
|
||||
public interface ISystemDirectories
|
||||
{
|
||||
string Bin { get; }
|
||||
string Config { get; }
|
||||
string Data { get; }
|
||||
string TempData { get; }
|
||||
string TempFileUploads { get; }
|
||||
string TempImageUploads { get; }
|
||||
string Install { get; }
|
||||
string AppCode { get; }
|
||||
string AppPlugins { get; }
|
||||
string MvcViews { get; }
|
||||
string PartialViews { get; }
|
||||
string MacroPartials { get; }
|
||||
string Media { get; }
|
||||
string Scripts { get; }
|
||||
string Css { get; }
|
||||
string Umbraco { get; }
|
||||
string Packages { get; }
|
||||
string Preview { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the root path of the application
|
||||
/// </summary>
|
||||
string Root
|
||||
{
|
||||
get;
|
||||
set; //Only required for unit tests
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ namespace Umbraco.Core.Composing.CompositionExtensions
|
||||
// register the IFileSystem supporting the IMediaFileSystem
|
||||
// THIS IS THE ONLY THING THAT NEEDS TO CHANGE, IN ORDER TO REPLACE THE UNDERLYING FILESYSTEM
|
||||
// and, SupportingFileSystem.For<IMediaFileSystem>() returns the underlying filesystem
|
||||
composition.SetMediaFileSystem(() => new PhysicalFileSystem(SystemDirectories.Media));
|
||||
composition.SetMediaFileSystem(() => new PhysicalFileSystem(Current.SystemDirectories.Media));
|
||||
|
||||
return composition;
|
||||
}
|
||||
|
||||
@@ -89,9 +89,10 @@ namespace Umbraco.Core.Composing.CompositionExtensions
|
||||
|
||||
private static LocalizedTextServiceFileSources SourcesFactory(IFactory container)
|
||||
{
|
||||
var mainLangFolder = new DirectoryInfo(Current.IOHelper.MapPath(SystemDirectories.Umbraco + "/config/lang/"));
|
||||
var appPlugins = new DirectoryInfo(Current.IOHelper.MapPath(SystemDirectories.AppPlugins));
|
||||
var configLangFolder = new DirectoryInfo(Current.IOHelper.MapPath(SystemDirectories.Config + "/lang/"));
|
||||
ISystemDirectories systemDirectories = new SystemDirectories();
|
||||
var mainLangFolder = new DirectoryInfo(Current.IOHelper.MapPath(systemDirectories.Umbraco + "/config/lang/"));
|
||||
var appPlugins = new DirectoryInfo(Current.IOHelper.MapPath(systemDirectories.AppPlugins));
|
||||
var configLangFolder = new DirectoryInfo(Current.IOHelper.MapPath(systemDirectories.Config + "/lang/"));
|
||||
|
||||
var pluginLangFolders = appPlugins.Exists == false
|
||||
? Enumerable.Empty<LocalizedTextServiceSupplementaryFileSource>()
|
||||
|
||||
@@ -205,7 +205,8 @@ namespace Umbraco.Core.Composing
|
||||
public static IVariationContextAccessor VariationContextAccessor
|
||||
=> Factory.GetInstance<IVariationContextAccessor>();
|
||||
|
||||
public static readonly IIOHelper IOHelper = new IOHelper();
|
||||
public static readonly IIOHelper IOHelper = Umbraco.Core.IO.IOHelper.Default;
|
||||
public static readonly ISystemDirectories SystemDirectories = new SystemDirectories();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Core
|
||||
|
||||
public static void AddCoreConfigs(this Configs configs)
|
||||
{
|
||||
var configDir = new DirectoryInfo(Current.IOHelper.MapPath(SystemDirectories.Config));
|
||||
var configDir = new DirectoryInfo(Current.IOHelper.MapPath(Current.SystemDirectories.Config));
|
||||
|
||||
configs.Add<IGlobalSettings>(() => new GlobalSettings());
|
||||
configs.Add<IUmbracoSettingsSection>("umbracoConfiguration/settings");
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace Umbraco.Core.Configuration
|
||||
/// <param name="value">Value of the setting to be saved.</param>
|
||||
internal static void SaveSetting(string key, string value)
|
||||
{
|
||||
var fileName = Current.IOHelper.MapPath(string.Format("{0}/web.config", SystemDirectories.Root));
|
||||
var fileName = Current.IOHelper.MapPath(string.Format("{0}/web.config", Current.SystemDirectories.Root));
|
||||
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
|
||||
|
||||
var appSettings = xml.Root.DescendantsAndSelf("appSettings").Single();
|
||||
@@ -193,7 +193,7 @@ namespace Umbraco.Core.Configuration
|
||||
/// <param name="key">Key of the setting to be removed.</param>
|
||||
internal static void RemoveSetting(string key)
|
||||
{
|
||||
var fileName = Current.IOHelper.MapPath(string.Format("{0}/web.config", SystemDirectories.Root));
|
||||
var fileName = Current.IOHelper.MapPath(string.Format("{0}/web.config", Current.SystemDirectories.Root));
|
||||
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
|
||||
|
||||
var appSettings = xml.Root.DescendantsAndSelf("appSettings").Single();
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Routing;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
@@ -42,8 +43,8 @@ namespace Umbraco.Core.Configuration
|
||||
}
|
||||
|
||||
var path = globalSettings.Path;
|
||||
if (path.StartsWith(SystemDirectories.Root)) // beware of TrimStart, see U4-2518
|
||||
path = path.Substring(SystemDirectories.Root.Length);
|
||||
if (path.StartsWith(Current.SystemDirectories.Root)) // beware of TrimStart, see U4-2518
|
||||
path = path.Substring(Current.SystemDirectories.Root.Length);
|
||||
return path.TrimStart('~').TrimStart('/').Replace('/', '-').Trim().ToLower();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
private readonly IFactory _container;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ISystemDirectories _systemDirectories;
|
||||
|
||||
private readonly ConcurrentDictionary<Type, Lazy<IFileSystem>> _filesystems = new ConcurrentDictionary<Type, Lazy<IFileSystem>>();
|
||||
|
||||
@@ -37,6 +38,7 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
_container = container;
|
||||
_logger = logger;
|
||||
_systemDirectories = Current.SystemDirectories;
|
||||
}
|
||||
|
||||
// for tests only, totally unsafe
|
||||
@@ -120,11 +122,11 @@ namespace Umbraco.Core.IO
|
||||
// but it does not really matter what we return - here, null
|
||||
private object CreateWellKnownFileSystems()
|
||||
{
|
||||
var macroPartialFileSystem = new PhysicalFileSystem(SystemDirectories.MacroPartials);
|
||||
var partialViewsFileSystem = new PhysicalFileSystem(SystemDirectories.PartialViews);
|
||||
var stylesheetsFileSystem = new PhysicalFileSystem(SystemDirectories.Css);
|
||||
var scriptsFileSystem = new PhysicalFileSystem(SystemDirectories.Scripts);
|
||||
var mvcViewsFileSystem = new PhysicalFileSystem(SystemDirectories.MvcViews);
|
||||
var macroPartialFileSystem = new PhysicalFileSystem(_systemDirectories.MacroPartials);
|
||||
var partialViewsFileSystem = new PhysicalFileSystem(_systemDirectories.PartialViews);
|
||||
var stylesheetsFileSystem = new PhysicalFileSystem(_systemDirectories.Css);
|
||||
var scriptsFileSystem = new PhysicalFileSystem(_systemDirectories.Scripts);
|
||||
var mvcViewsFileSystem = new PhysicalFileSystem(_systemDirectories.MvcViews);
|
||||
|
||||
_macroPartialFileSystem = new ShadowWrapper(macroPartialFileSystem, "macro-partials", IsScoped);
|
||||
_partialViewsFileSystem = new ShadowWrapper(partialViewsFileSystem, "partials", IsScoped);
|
||||
|
||||
@@ -13,7 +13,13 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
public class IOHelper : IIOHelper
|
||||
{
|
||||
internal static IIOHelper Default { get; } = new IOHelper();
|
||||
private readonly ISystemDirectories _systemDirectories;
|
||||
internal static IIOHelper Default { get; } = new IOHelper(new SystemDirectories());
|
||||
|
||||
public IOHelper(ISystemDirectories systemDirectories)
|
||||
{
|
||||
_systemDirectories = systemDirectories;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value forcing Umbraco to consider it is non-hosted.
|
||||
@@ -39,10 +45,10 @@ namespace Umbraco.Core.IO
|
||||
string retval = virtualPath;
|
||||
|
||||
if (virtualPath.StartsWith("~"))
|
||||
retval = virtualPath.Replace("~", SystemDirectories.Root);
|
||||
retval = virtualPath.Replace("~", _systemDirectories.Root);
|
||||
|
||||
if (virtualPath.StartsWith("/") && virtualPath.StartsWith(SystemDirectories.Root) == false)
|
||||
retval = SystemDirectories.Root + "/" + virtualPath.TrimStart('/');
|
||||
if (virtualPath.StartsWith("/") && virtualPath.StartsWith(_systemDirectories.Root) == false)
|
||||
retval = _systemDirectories.Root + "/" + virtualPath.TrimStart('/');
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -57,11 +63,11 @@ namespace Umbraco.Core.IO
|
||||
public string ResolveUrl(string virtualPath)
|
||||
{
|
||||
if (virtualPath.StartsWith("~"))
|
||||
return virtualPath.Replace("~", SystemDirectories.Root).Replace("//", "/");
|
||||
return virtualPath.Replace("~", _systemDirectories.Root).Replace("//", "/");
|
||||
else if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
|
||||
return virtualPath;
|
||||
else
|
||||
return VirtualPathUtility.ToAbsolute(virtualPath, SystemDirectories.Root);
|
||||
return VirtualPathUtility.ToAbsolute(virtualPath, _systemDirectories.Root);
|
||||
}
|
||||
|
||||
public Attempt<string> TryResolveUrl(string virtualPath)
|
||||
@@ -69,10 +75,10 @@ namespace Umbraco.Core.IO
|
||||
try
|
||||
{
|
||||
if (virtualPath.StartsWith("~"))
|
||||
return Attempt.Succeed(virtualPath.Replace("~", SystemDirectories.Root).Replace("//", "/"));
|
||||
return Attempt.Succeed(virtualPath.Replace("~", _systemDirectories.Root).Replace("//", "/"));
|
||||
if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
|
||||
return Attempt.Succeed(virtualPath);
|
||||
return Attempt.Succeed(VirtualPathUtility.ToAbsolute(virtualPath, SystemDirectories.Root));
|
||||
return Attempt.Succeed(VirtualPathUtility.ToAbsolute(virtualPath, _systemDirectories.Root));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -97,7 +103,7 @@ namespace Umbraco.Core.IO
|
||||
if (useHttpContext && HttpContext.Current != null)
|
||||
{
|
||||
//string retval;
|
||||
if (String.IsNullOrEmpty(path) == false && (path.StartsWith("~") || path.StartsWith(SystemDirectories.Root)))
|
||||
if (String.IsNullOrEmpty(path) == false && (path.StartsWith("~") || path.StartsWith(_systemDirectories.Root)))
|
||||
return HostingEnvironment.MapPath(path);
|
||||
else
|
||||
return HostingEnvironment.MapPath("~/" + path.TrimStart('/'));
|
||||
@@ -160,7 +166,7 @@ namespace Umbraco.Core.IO
|
||||
// TODO: what's below is dirty, there are too many ways to get the root dir, etc.
|
||||
// not going to fix everything today
|
||||
|
||||
var mappedRoot = MapPath(SystemDirectories.Root);
|
||||
var mappedRoot = MapPath(_systemDirectories.Root);
|
||||
if (filePath.StartsWith(mappedRoot) == false)
|
||||
filePath = MapPath(filePath);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Umbraco.Core.IO
|
||||
{
|
||||
internal class ShadowWrapper : IFileSystem
|
||||
{
|
||||
private static readonly string ShadowFsPath = SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs";
|
||||
private static readonly string ShadowFsPath = Current.SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs";
|
||||
|
||||
private readonly Func<bool> _isScoped;
|
||||
private readonly IFileSystem _innerFileSystem;
|
||||
|
||||
@@ -4,50 +4,50 @@ using Umbraco.Core.Composing;
|
||||
namespace Umbraco.Core.IO
|
||||
{
|
||||
//all paths has a starting but no trailing /
|
||||
public class SystemDirectories
|
||||
public class SystemDirectories : ISystemDirectories
|
||||
{
|
||||
public static string Bin => "~/bin";
|
||||
public string Bin => "~/bin";
|
||||
|
||||
public static string Config => "~/config";
|
||||
public string Config => "~/config";
|
||||
|
||||
public static string Data => "~/App_Data";
|
||||
public string Data => "~/App_Data";
|
||||
|
||||
public static string TempData => Data + "/TEMP";
|
||||
public string TempData => Data + "/TEMP";
|
||||
|
||||
public static string TempFileUploads => TempData + "/FileUploads";
|
||||
public string TempFileUploads => TempData + "/FileUploads";
|
||||
|
||||
public static string TempImageUploads => TempFileUploads + "/rte";
|
||||
public string TempImageUploads => TempFileUploads + "/rte";
|
||||
|
||||
public static string Install => "~/install";
|
||||
public string Install => "~/install";
|
||||
|
||||
public static string AppCode => "~/App_Code";
|
||||
public string AppCode => "~/App_Code";
|
||||
|
||||
public static string AppPlugins => "~/App_Plugins";
|
||||
public string AppPlugins => "~/App_Plugins";
|
||||
|
||||
public static string MvcViews => "~/Views";
|
||||
public string MvcViews => "~/Views";
|
||||
|
||||
public static string PartialViews => MvcViews + "/Partials/";
|
||||
public string PartialViews => MvcViews + "/Partials/";
|
||||
|
||||
public static string MacroPartials => MvcViews + "/MacroPartials/";
|
||||
public string MacroPartials => MvcViews + "/MacroPartials/";
|
||||
|
||||
public static string Media => Current.IOHelper.ReturnPath("umbracoMediaPath", "~/media");
|
||||
public string Media => Current.IOHelper.ReturnPath("umbracoMediaPath", "~/media");
|
||||
|
||||
public static string Scripts => Current.IOHelper.ReturnPath("umbracoScriptsPath", "~/scripts");
|
||||
public string Scripts => Current.IOHelper.ReturnPath("umbracoScriptsPath", "~/scripts");
|
||||
|
||||
public static string Css => Current.IOHelper.ReturnPath("umbracoCssPath", "~/css");
|
||||
public string Css => Current.IOHelper.ReturnPath("umbracoCssPath", "~/css");
|
||||
|
||||
public static string Umbraco => Current.IOHelper.ReturnPath("umbracoPath", "~/umbraco");
|
||||
public string Umbraco => Current.IOHelper.ReturnPath("umbracoPath", "~/umbraco");
|
||||
|
||||
public static string Packages => Data + "/packages";
|
||||
public string Packages => Data + "/packages";
|
||||
|
||||
public static string Preview => Data + "/preview";
|
||||
public string Preview => Data + "/preview";
|
||||
|
||||
private static string _root;
|
||||
private string _root;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the root path of the application
|
||||
/// </summary>
|
||||
public static string Root
|
||||
public string Root
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -62,7 +62,7 @@ namespace Umbraco.Core.IO
|
||||
return _root;
|
||||
}
|
||||
//Only required for unit tests
|
||||
internal set => _root = value;
|
||||
set => _root = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System.IO;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.IO
|
||||
{
|
||||
public class SystemFiles
|
||||
{
|
||||
public static string TinyMceConfig => SystemDirectories.Config + "/tinyMceConfig.config";
|
||||
public static string TinyMceConfig => Current.SystemDirectories.Config + "/tinyMceConfig.config";
|
||||
|
||||
// TODO: Kill this off we don't have umbraco.config XML cache we now have NuCache
|
||||
public static string GetContentCacheXml(IGlobalSettings globalSettings)
|
||||
|
||||
@@ -283,7 +283,7 @@ namespace Umbraco.Core.Migrations.Install
|
||||
if (string.IsNullOrWhiteSpace(providerName)) throw new ArgumentNullOrEmptyException(nameof(providerName));
|
||||
|
||||
var fileSource = "web.config";
|
||||
var fileName = Current.IOHelper.MapPath(SystemDirectories.Root +"/" + fileSource);
|
||||
var fileName = Current.IOHelper.MapPath(Current.SystemDirectories.Root +"/" + fileSource);
|
||||
|
||||
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
|
||||
if (xml.Root == null) throw new Exception($"Invalid {fileSource} file (no root).");
|
||||
@@ -296,7 +296,7 @@ namespace Umbraco.Core.Migrations.Install
|
||||
if (configSourceAttribute != null)
|
||||
{
|
||||
fileSource = configSourceAttribute.Value;
|
||||
fileName = Current.IOHelper.MapPath(SystemDirectories.Root + "/" + fileSource);
|
||||
fileName = Current.IOHelper.MapPath(Current.SystemDirectories.Root + "/" + fileSource);
|
||||
|
||||
if (!File.Exists(fileName))
|
||||
throw new Exception($"Invalid configSource \"{fileSource}\" (no such file).");
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Packaging;
|
||||
@@ -131,15 +132,15 @@ namespace Umbraco.Core.Packaging
|
||||
{
|
||||
return pathElement.TrimStart(new[] { '\\', '/', '~' }).Replace("/", "\\");
|
||||
}
|
||||
|
||||
|
||||
private static string UpdatePathPlaceholders(string path)
|
||||
{
|
||||
if (path.Contains("[$"))
|
||||
{
|
||||
//this is experimental and undocumented...
|
||||
path = path.Replace("[$UMBRACO]", SystemDirectories.Umbraco);
|
||||
path = path.Replace("[$CONFIG]", SystemDirectories.Config);
|
||||
path = path.Replace("[$DATA]", SystemDirectories.Data);
|
||||
path = path.Replace("[$UMBRACO]", Current.SystemDirectories.Umbraco);
|
||||
path = path.Replace("[$CONFIG]", Current.SystemDirectories.Config);
|
||||
path = path.Replace("[$DATA]", Current.SystemDirectories.Data);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Web;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using Umbraco.Core.Collections;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -1317,7 +1318,7 @@ namespace Umbraco.Core.Packaging
|
||||
|
||||
private string ViewPath(string alias)
|
||||
{
|
||||
return SystemDirectories.MvcViews + "/" + alias.Replace(" ", "") + ".cshtml";
|
||||
return Current.SystemDirectories.MvcViews + "/" + alias.Replace(" ", "") + ".cshtml";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -70,9 +70,9 @@ namespace Umbraco.Core.Packaging
|
||||
_logger = logger;
|
||||
_packageRepositoryFileName = packageRepositoryFileName;
|
||||
|
||||
_tempFolderPath = tempFolderPath ?? SystemDirectories.TempData.EnsureEndsWith('/') + "PackageFiles";
|
||||
_packagesFolderPath = packagesFolderPath ?? SystemDirectories.Packages;
|
||||
_mediaFolderPath = mediaFolderPath ?? SystemDirectories.Media + "/created-packages";
|
||||
_tempFolderPath = tempFolderPath ?? Current.SystemDirectories.TempData.EnsureEndsWith('/') + "PackageFiles";
|
||||
_packagesFolderPath = packagesFolderPath ?? Current.SystemDirectories.Packages;
|
||||
_mediaFolderPath = mediaFolderPath ?? Current.SystemDirectories.Media + "/created-packages";
|
||||
|
||||
_parser = new PackageDefinitionXmlParser(logger);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
}
|
||||
|
||||
// validate path & extension
|
||||
var validDir = SystemDirectories.MvcViews;
|
||||
var validDir = Current.SystemDirectories.MvcViews;
|
||||
var isValidPath = Current.IOHelper.VerifyEditPath(fullPath, validDir);
|
||||
var isValidExtension = Current.IOHelper.VerifyFileExtension(fullPath, ValidExtensions);
|
||||
return isValidPath && isValidExtension;
|
||||
|
||||
@@ -15,11 +15,13 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
internal class ScriptRepository : FileRepository<string, IScript>, IScriptRepository
|
||||
{
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly ISystemDirectories _systemDirectories;
|
||||
|
||||
public ScriptRepository(IFileSystems fileSystems, IIOHelper ioHelper)
|
||||
: base(fileSystems.ScriptsFileSystem)
|
||||
{
|
||||
_ioHelper = ioHelper ?? throw new ArgumentNullException(nameof(ioHelper));
|
||||
_systemDirectories = Current.SystemDirectories;
|
||||
}
|
||||
|
||||
#region Implementation of IRepository<string,Script>
|
||||
@@ -104,7 +106,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
}
|
||||
|
||||
// validate path & extension
|
||||
var validDir = SystemDirectories.Scripts;
|
||||
var validDir = _systemDirectories.Scripts;
|
||||
var isValidPath = _ioHelper.VerifyEditPath(fullPath, validDir);
|
||||
var validExts = new[] {"js"};
|
||||
var isValidExtension = _ioHelper.VerifyFileExtension(script.Path, validExts);
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
}
|
||||
|
||||
// validate path and extension
|
||||
var validDir = SystemDirectories.Css;
|
||||
var validDir = Current.SystemDirectories.Css;
|
||||
var isValidPath = _ioHelper.VerifyEditPath(fullPath, validDir);
|
||||
var isValidExtension = _ioHelper.VerifyFileExtension(stylesheet.Path, ValidExtensions);
|
||||
return isValidPath && isValidExtension;
|
||||
|
||||
@@ -585,7 +585,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
var path = template.VirtualPath;
|
||||
|
||||
// get valid paths
|
||||
var validDirs = new[] { SystemDirectories.MvcViews };
|
||||
var validDirs = new[] { Current.SystemDirectories.MvcViews };
|
||||
|
||||
// get valid extensions
|
||||
var validExts = new List<string>();
|
||||
|
||||
@@ -10,10 +10,10 @@ namespace Umbraco.Core.Runtime
|
||||
// ensure we have some essential directories
|
||||
// every other component can then initialize safely
|
||||
Current.IOHelper.EnsurePathExists("~/App_Data");
|
||||
Current.IOHelper.EnsurePathExists(SystemDirectories.Media);
|
||||
Current.IOHelper.EnsurePathExists(SystemDirectories.MvcViews);
|
||||
Current.IOHelper.EnsurePathExists(SystemDirectories.MvcViews + "/Partials");
|
||||
Current.IOHelper.EnsurePathExists(SystemDirectories.MvcViews + "/MacroPartials");
|
||||
Current.IOHelper.EnsurePathExists(Current.SystemDirectories.Media);
|
||||
Current.IOHelper.EnsurePathExists(Current.SystemDirectories.MvcViews);
|
||||
Current.IOHelper.EnsurePathExists(Current.SystemDirectories.MvcViews + "/Partials");
|
||||
Current.IOHelper.EnsurePathExists(Current.SystemDirectories.MvcViews + "/MacroPartials");
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
|
||||
@@ -664,7 +664,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
public IEnumerable<string> GetPartialViewSnippetNames(params string[] filterNames)
|
||||
{
|
||||
var snippetPath = Current.IOHelper.MapPath($"{SystemDirectories.Umbraco}/PartialViewMacros/Templates/");
|
||||
var snippetPath = Current.IOHelper.MapPath($"{Current.SystemDirectories.Umbraco}/PartialViewMacros/Templates/");
|
||||
var files = Directory.GetFiles(snippetPath, "*.cshtml")
|
||||
.Select(Path.GetFileNameWithoutExtension)
|
||||
.Except(filterNames, StringComparer.InvariantCultureIgnoreCase)
|
||||
@@ -898,7 +898,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
fileName += ".cshtml";
|
||||
}
|
||||
|
||||
var snippetPath = Current.IOHelper.MapPath($"{SystemDirectories.Umbraco}/PartialViewMacros/Templates/{fileName}");
|
||||
var snippetPath = Current.IOHelper.MapPath($"{Current.SystemDirectories.Umbraco}/PartialViewMacros/Templates/{fileName}");
|
||||
return System.IO.File.Exists(snippetPath)
|
||||
? Attempt<string>.Succeed(snippetPath)
|
||||
: Attempt<string>.Fail();
|
||||
|
||||
@@ -384,7 +384,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
var protocol = _globalSettings.UseHttps ? "https" : "http";
|
||||
|
||||
var subjectVars = new NotificationEmailSubjectParams(
|
||||
string.Concat(siteUri.Authority, Current.IOHelper.ResolveUrl(SystemDirectories.Umbraco)),
|
||||
string.Concat(siteUri.Authority, Current.IOHelper.ResolveUrl(Current.SystemDirectories.Umbraco)),
|
||||
actionName,
|
||||
content.Name);
|
||||
|
||||
@@ -400,7 +400,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
string.Concat(content.Id, ".aspx"),
|
||||
protocol),
|
||||
performingUser.Name,
|
||||
string.Concat(siteUri.Authority, Current.IOHelper.ResolveUrl(SystemDirectories.Umbraco)),
|
||||
string.Concat(siteUri.Authority, Current.IOHelper.ResolveUrl(Current.SystemDirectories.Umbraco)),
|
||||
summary.ToString());
|
||||
|
||||
// create the mail message
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
//successful
|
||||
if (bytes.Length > 0)
|
||||
{
|
||||
var packagePath = Current.IOHelper.MapPath(SystemDirectories.Packages);
|
||||
var packagePath = Current.IOHelper.MapPath(Current.SystemDirectories.Packages);
|
||||
|
||||
// Check for package directory
|
||||
if (Directory.Exists(packagePath) == false)
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Umbraco.Core.Sync
|
||||
: "";
|
||||
|
||||
var ssl = globalSettings.UseHttps ? "s" : ""; // force, whatever the first request
|
||||
var url = "http" + ssl + "://" + request.ServerVariables["SERVER_NAME"] + port + Current.IOHelper.ResolveUrl(SystemDirectories.Umbraco);
|
||||
var url = "http" + ssl + "://" + request.ServerVariables["SERVER_NAME"] + port + Current.IOHelper.ResolveUrl(Current.SystemDirectories.Umbraco);
|
||||
|
||||
return url.TrimEnd('/');
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Umbraco.Examine
|
||||
public virtual Lucene.Net.Store.Directory CreateFileSystemLuceneDirectory(string folderName)
|
||||
{
|
||||
|
||||
var dirInfo = new DirectoryInfo(Path.Combine(Current.IOHelper.MapPath(SystemDirectories.TempData), "ExamineIndexes", folderName));
|
||||
var dirInfo = new DirectoryInfo(Path.Combine(Current.IOHelper.MapPath(Current.SystemDirectories.TempData), "ExamineIndexes", folderName));
|
||||
if (!dirInfo.Exists)
|
||||
System.IO.Directory.CreateDirectory(dirInfo.FullName);
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Umbraco.Examine
|
||||
|
||||
if (luceneDir is FSDirectory fsDir)
|
||||
{
|
||||
d[nameof(UmbracoExamineIndex.LuceneIndexFolder)] = fsDir.Directory.ToString().ToLowerInvariant().TrimStart(Current.IOHelper.MapPath(SystemDirectories.Root).ToLowerInvariant()).Replace("\\", "/").EnsureStartsWith('/');
|
||||
d[nameof(UmbracoExamineIndex.LuceneIndexFolder)] = fsDir.Directory.ToString().ToLowerInvariant().TrimStart(Current.IOHelper.MapPath(Current.SystemDirectories.Root).ToLowerInvariant()).Replace("\\", "/").EnsureStartsWith('/');
|
||||
}
|
||||
|
||||
return d;
|
||||
|
||||
@@ -17,13 +17,13 @@ namespace Umbraco.Tests.Configurations
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
_root = SystemDirectories.Root;
|
||||
_root = Current.SystemDirectories.Root;
|
||||
}
|
||||
|
||||
public override void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
SystemDirectories.Root = _root;
|
||||
Current.SystemDirectories.Root = _root;
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -51,7 +51,7 @@ namespace Umbraco.Tests.Configurations
|
||||
var globalSettingsMock = Mock.Get(globalSettings);
|
||||
globalSettingsMock.Setup(x => x.Path).Returns(() => Current.IOHelper.ResolveUrl(path));
|
||||
|
||||
SystemDirectories.Root = rootPath;
|
||||
Current.SystemDirectories.Root = rootPath;
|
||||
Assert.AreEqual(outcome, globalSettings.GetUmbracoMvcAreaNoCache());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
@@ -14,13 +15,13 @@ namespace Umbraco.Tests.CoreThings
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_root = SystemDirectories.Root;
|
||||
_root = Current.SystemDirectories.Root;
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
SystemDirectories.Root = _root;
|
||||
Current.SystemDirectories.Root = _root;
|
||||
}
|
||||
|
||||
[TestCase("http://www.domain.com/umbraco", "", true)]
|
||||
@@ -32,7 +33,7 @@ namespace Umbraco.Tests.CoreThings
|
||||
[TestCase("http://www.domain.com/umbraco/test/test.js", "", true)]
|
||||
[TestCase("http://www.domain.com/umbrac", "", false)]
|
||||
[TestCase("http://www.domain.com/test", "", false)]
|
||||
[TestCase("http://www.domain.com/test/umbraco", "", false)]
|
||||
[TestCase("http://www.domain.com/test/umbraco", "", false)]
|
||||
[TestCase("http://www.domain.com/Umbraco/Backoffice/blah", "", true)]
|
||||
[TestCase("http://www.domain.com/Umbraco/anything", "", true)]
|
||||
[TestCase("http://www.domain.com/Umbraco/anything/", "", true)]
|
||||
@@ -44,7 +45,7 @@ namespace Umbraco.Tests.CoreThings
|
||||
[TestCase("http://www.domain.com/umbraco/test/legacyAjaxCalls.ashx?some=query&blah=js", "", true)]
|
||||
public void Is_Back_Office_Request(string input, string virtualPath, bool expected)
|
||||
{
|
||||
SystemDirectories.Root = virtualPath;
|
||||
Current.SystemDirectories.Root = virtualPath;
|
||||
var globalConfig = SettingsForTests.GenerateMockGlobalSettings();
|
||||
var source = new Uri(input);
|
||||
Assert.AreEqual(expected, source.IsBackOfficeRequest(virtualPath, globalConfig));
|
||||
@@ -58,7 +59,7 @@ namespace Umbraco.Tests.CoreThings
|
||||
[TestCase("http://www.domain.com/install/test/test.js", true)]
|
||||
[TestCase("http://www.domain.com/instal", false)]
|
||||
[TestCase("http://www.domain.com/umbraco", false)]
|
||||
[TestCase("http://www.domain.com/umbraco/umbraco", false)]
|
||||
[TestCase("http://www.domain.com/umbraco/umbraco", false)]
|
||||
public void Is_Installer_Request(string input, bool expected)
|
||||
{
|
||||
var source = new Uri(input);
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace Umbraco.Tests.IO
|
||||
[TestFixture]
|
||||
public class IoHelperTests
|
||||
{
|
||||
private ISystemDirectories SystemDirectories => Current.SystemDirectories;
|
||||
|
||||
[TestCase("~/Scripts", "/Scripts", null)]
|
||||
[TestCase("/Scripts", "/Scripts", null)]
|
||||
[TestCase("../Scripts", "/Scripts", typeof(ArgumentException))]
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Tests.IO
|
||||
private static void ClearFiles()
|
||||
{
|
||||
TestHelper.DeleteDirectory(Current.IOHelper.MapPath("FileSysTests"));
|
||||
TestHelper.DeleteDirectory(Current.IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs"));
|
||||
TestHelper.DeleteDirectory(Current.IOHelper.MapPath(Current.SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs"));
|
||||
}
|
||||
|
||||
private static string NormPath(string path)
|
||||
@@ -388,7 +388,7 @@ namespace Umbraco.Tests.IO
|
||||
var logger = Mock.Of<ILogger>();
|
||||
|
||||
var path = Current.IOHelper.MapPath("FileSysTests");
|
||||
var shadowfs = Current.IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs");
|
||||
var shadowfs = Current.IOHelper.MapPath(Current.SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs");
|
||||
Directory.CreateDirectory(path);
|
||||
Directory.CreateDirectory(shadowfs);
|
||||
|
||||
@@ -483,7 +483,7 @@ namespace Umbraco.Tests.IO
|
||||
var logger = Mock.Of<ILogger>();
|
||||
|
||||
var path = Current.IOHelper.MapPath("FileSysTests");
|
||||
var shadowfs = Current.IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs");
|
||||
var shadowfs = Current.IOHelper.MapPath(Current.SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs");
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
var scopedFileSystems = false;
|
||||
@@ -536,7 +536,7 @@ namespace Umbraco.Tests.IO
|
||||
var logger = Mock.Of<ILogger>();
|
||||
|
||||
var path = Current.IOHelper.MapPath("FileSysTests");
|
||||
var shadowfs = Current.IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs");
|
||||
var shadowfs = Current.IOHelper.MapPath(Current.SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs");
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
var scopedFileSystems = false;
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
_previewXml = _xmlStore.GetPreviewXml(contentId, includeSubs);
|
||||
|
||||
// make sure the preview folder exists
|
||||
var dir = new DirectoryInfo(Current.IOHelper.MapPath(SystemDirectories.Preview));
|
||||
var dir = new DirectoryInfo(Current.IOHelper.MapPath(Current.SystemDirectories.Preview));
|
||||
if (dir.Exists == false)
|
||||
dir.Create();
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
|
||||
// get the full path to the preview set
|
||||
private static string GetPreviewSetPath(int userId, Guid previewSet)
|
||||
{
|
||||
return Current.IOHelper.MapPath(Path.Combine(SystemDirectories.Preview, userId + "_" + previewSet + ".config"));
|
||||
return Current.IOHelper.MapPath(Path.Combine(Current.SystemDirectories.Preview, userId + "_" + previewSet + ".config"));
|
||||
}
|
||||
|
||||
// deletes files for the user, and files accessed more than one hour ago
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
@@ -20,7 +21,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
_fileSystem = new PhysicalFileSystem(SystemDirectories.MvcViews + "/Partials/");
|
||||
_fileSystem = new PhysicalFileSystem(Current.SystemDirectories.MvcViews + "/Partials/");
|
||||
}
|
||||
|
||||
protected override void Compose()
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -26,7 +27,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
base.SetUp();
|
||||
|
||||
_fileSystems = Mock.Of<IFileSystems>();
|
||||
_fileSystem = new PhysicalFileSystem(SystemDirectories.Scripts);
|
||||
_fileSystem = new PhysicalFileSystem(Current.SystemDirectories.Scripts);
|
||||
Mock.Get(_fileSystems).Setup(x => x.ScriptsFileSystem).Returns(_fileSystem);
|
||||
using (var stream = CreateStream("Umbraco.Sys.registerNamespace(\"Umbraco.Utils\");"))
|
||||
{
|
||||
@@ -36,7 +37,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
private IScriptRepository CreateRepository()
|
||||
{
|
||||
return new ScriptRepository(_fileSystems, new IOHelper());
|
||||
return new ScriptRepository(_fileSystems, IOHelper);
|
||||
}
|
||||
|
||||
protected override void Compose()
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
@@ -25,7 +26,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
base.SetUp();
|
||||
|
||||
_fileSystems = Mock.Of<IFileSystems>();
|
||||
_fileSystem = new PhysicalFileSystem(SystemDirectories.Css);
|
||||
_fileSystem = new PhysicalFileSystem(Current.SystemDirectories.Css);
|
||||
Mock.Get(_fileSystems).Setup(x => x.StylesheetsFileSystem).Returns(_fileSystem);
|
||||
var stream = CreateStream("body {background:#EE7600; color:#FFF;}");
|
||||
_fileSystem.AddFile("styles.css", stream);
|
||||
@@ -33,7 +34,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
private IStylesheetRepository CreateRepository()
|
||||
{
|
||||
return new StylesheetRepository(_fileSystems, new IOHelper());
|
||||
return new StylesheetRepository(_fileSystems, IOHelper);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -7,6 +7,7 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -35,7 +36,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
base.SetUp();
|
||||
|
||||
_fileSystems = Mock.Of<IFileSystems>();
|
||||
var viewsFileSystem = new PhysicalFileSystem(SystemDirectories.MvcViews);
|
||||
var viewsFileSystem = new PhysicalFileSystem(Current.SystemDirectories.MvcViews);
|
||||
Mock.Get(_fileSystems).Setup(x => x.MvcViewsFileSystem).Returns(viewsFileSystem);
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Act
|
||||
var template = new Template("test", "test");
|
||||
repository.Save(template);
|
||||
|
||||
|
||||
|
||||
//Assert
|
||||
Assert.That(repository.Get("test"), Is.Not.Null);
|
||||
@@ -526,7 +527,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
_fileSystems = null;
|
||||
|
||||
//Delete all files
|
||||
var fsViews = new PhysicalFileSystem(SystemDirectories.MvcViews);
|
||||
var fsViews = new PhysicalFileSystem(Current.SystemDirectories.MvcViews);
|
||||
var views = fsViews.GetFiles("", "*.cshtml");
|
||||
foreach (var file in views)
|
||||
fsViews.DeleteFile(file);
|
||||
@@ -615,7 +616,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.Save(toddler4);
|
||||
repository.Save(baby1);
|
||||
repository.Save(baby2);
|
||||
|
||||
|
||||
|
||||
return new[] {parent, child1, child2, toddler1, toddler2, toddler3, toddler4, baby1, baby2};
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Umbraco.Tests.Scoping
|
||||
{
|
||||
TestHelper.DeleteDirectory(Current.IOHelper.MapPath("media"));
|
||||
TestHelper.DeleteDirectory(Current.IOHelper.MapPath("FileSysTests"));
|
||||
TestHelper.DeleteDirectory(Current.IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs"));
|
||||
TestHelper.DeleteDirectory(Current.IOHelper.MapPath(Current.SystemDirectories.TempData.EnsureEndsWith('/') + "ShadowFs"));
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
|
||||
@@ -62,12 +62,12 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|
||||
public static void InitializeContentDirectories()
|
||||
{
|
||||
CreateDirectories(new[] { SystemDirectories.MvcViews, SystemDirectories.Media, SystemDirectories.AppPlugins });
|
||||
CreateDirectories(new[] { Current.SystemDirectories.MvcViews, Current.SystemDirectories.Media, Current.SystemDirectories.AppPlugins });
|
||||
}
|
||||
|
||||
public static void CleanContentDirectories()
|
||||
{
|
||||
CleanDirectories(new[] { SystemDirectories.MvcViews, SystemDirectories.Media });
|
||||
CleanDirectories(new[] { Current.SystemDirectories.MvcViews, Current.SystemDirectories.Media });
|
||||
}
|
||||
|
||||
public static void CreateDirectories(string[] directories)
|
||||
@@ -84,7 +84,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
var preserves = new Dictionary<string, string[]>
|
||||
{
|
||||
{ SystemDirectories.MvcViews, new[] {"dummy.txt"} }
|
||||
{ Current.SystemDirectories.MvcViews, new[] {"dummy.txt"} }
|
||||
};
|
||||
foreach (var directory in directories)
|
||||
{
|
||||
|
||||
@@ -118,9 +118,9 @@ namespace Umbraco.Tests.TestHelpers
|
||||
var localizedTextService = GetLazyService<ILocalizedTextService>(factory, c => new LocalizedTextService(
|
||||
new Lazy<LocalizedTextServiceFileSources>(() =>
|
||||
{
|
||||
var mainLangFolder = new DirectoryInfo(Current.IOHelper.MapPath(SystemDirectories.Umbraco + "/config/lang/"));
|
||||
var appPlugins = new DirectoryInfo(Current.IOHelper.MapPath(SystemDirectories.AppPlugins));
|
||||
var configLangFolder = new DirectoryInfo(Current.IOHelper.MapPath(SystemDirectories.Config + "/lang/"));
|
||||
var mainLangFolder = new DirectoryInfo(Current.IOHelper.MapPath(Current.SystemDirectories.Umbraco + "/config/lang/"));
|
||||
var appPlugins = new DirectoryInfo(Current.IOHelper.MapPath(Current.SystemDirectories.AppPlugins));
|
||||
var configLangFolder = new DirectoryInfo(Current.IOHelper.MapPath(Current.SystemDirectories.Config + "/lang/"));
|
||||
|
||||
var pluginLangFolders = appPlugins.Exists == false
|
||||
? Enumerable.Empty<LocalizedTextServiceSupplementaryFileSource>()
|
||||
|
||||
@@ -227,6 +227,7 @@ namespace Umbraco.Web.Composing
|
||||
public static IVariationContextAccessor VariationContextAccessor => CoreCurrent.VariationContextAccessor;
|
||||
|
||||
public static IIOHelper IOHelper => CoreCurrent.IOHelper;
|
||||
public static ISystemDirectories SystemDirectories => CoreCurrent.SystemDirectories;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Umbraco.Web.Editors
|
||||
[PluginController("UmbracoApi")]
|
||||
public class BackOfficeAssetsController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
private readonly IFileSystem _jsLibFileSystem = new PhysicalFileSystem(SystemDirectories.Umbraco + Current.IOHelper.DirSepChar + "lib");
|
||||
private readonly IFileSystem _jsLibFileSystem = new PhysicalFileSystem(Current.SystemDirectories.Umbraco + Current.IOHelper.DirSepChar + "lib");
|
||||
|
||||
[HttpGet]
|
||||
public object GetSupportedLocales()
|
||||
|
||||
@@ -320,8 +320,8 @@ namespace Umbraco.Web.Editors
|
||||
"umbracoSettings", new Dictionary<string, object>
|
||||
{
|
||||
{"umbracoPath", _globalSettings.Path},
|
||||
{"mediaPath", Current.IOHelper.ResolveUrl(SystemDirectories.Media).TrimEnd('/')},
|
||||
{"appPluginsPath", Current.IOHelper.ResolveUrl(SystemDirectories.AppPlugins).TrimEnd('/')},
|
||||
{"mediaPath", Current.IOHelper.ResolveUrl(Current.SystemDirectories.Media).TrimEnd('/')},
|
||||
{"appPluginsPath", Current.IOHelper.ResolveUrl(Current.SystemDirectories.AppPlugins).TrimEnd('/')},
|
||||
{
|
||||
"imageFileTypes",
|
||||
string.Join(",", Current.Configs.Settings().Content.ImageFileTypes)
|
||||
@@ -340,7 +340,7 @@ namespace Umbraco.Web.Editors
|
||||
},
|
||||
{"keepUserLoggedIn", Current.Configs.Settings().Security.KeepUserLoggedIn},
|
||||
{"usernameIsEmail", Current.Configs.Settings().Security.UsernameIsEmail},
|
||||
{"cssPath", Current.IOHelper.ResolveUrl(SystemDirectories.Css).TrimEnd('/')},
|
||||
{"cssPath", Current.IOHelper.ResolveUrl(Current.SystemDirectories.Css).TrimEnd('/')},
|
||||
{"allowPasswordReset", Current.Configs.Settings().Security.AllowPasswordReset},
|
||||
{"loginBackgroundImage", Current.Configs.Settings().Content.LoginBackgroundImage},
|
||||
{"showUserInvite", EmailSender.CanSendRequiredEmail},
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Controllers;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Editors;
|
||||
@@ -20,7 +21,7 @@ namespace Umbraco.Web.Editors.Binders
|
||||
public TModelSave BindModelFromMultipartRequest<TModelSave>(HttpActionContext actionContext, ModelBindingContext bindingContext)
|
||||
where TModelSave : IHaveUploadedFiles
|
||||
{
|
||||
var result = actionContext.ReadAsMultipart(SystemDirectories.TempFileUploads);
|
||||
var result = actionContext.ReadAsMultipart(Current.SystemDirectories.TempFileUploads);
|
||||
|
||||
var model = actionContext.GetModelFromMultipartRequest<TModelSave>(result, "contentItem");
|
||||
|
||||
|
||||
@@ -110,19 +110,19 @@ namespace Umbraco.Web.Editors
|
||||
switch (type)
|
||||
{
|
||||
case Core.Constants.Trees.PartialViews:
|
||||
virtualPath = NormalizeVirtualPath(name, SystemDirectories.PartialViews);
|
||||
virtualPath = NormalizeVirtualPath(name, Current.SystemDirectories.PartialViews);
|
||||
Services.FileService.CreatePartialViewFolder(virtualPath);
|
||||
break;
|
||||
case Core.Constants.Trees.PartialViewMacros:
|
||||
virtualPath = NormalizeVirtualPath(name, SystemDirectories.MacroPartials);
|
||||
virtualPath = NormalizeVirtualPath(name, Current.SystemDirectories.MacroPartials);
|
||||
Services.FileService.CreatePartialViewMacroFolder(virtualPath);
|
||||
break;
|
||||
case Core.Constants.Trees.Scripts:
|
||||
virtualPath = NormalizeVirtualPath(name, SystemDirectories.Scripts);
|
||||
virtualPath = NormalizeVirtualPath(name, Current.SystemDirectories.Scripts);
|
||||
Services.FileService.CreateScriptFolder(virtualPath);
|
||||
break;
|
||||
case Core.Constants.Trees.Stylesheets:
|
||||
virtualPath = NormalizeVirtualPath(name, SystemDirectories.Css);
|
||||
virtualPath = NormalizeVirtualPath(name, Current.SystemDirectories.Css);
|
||||
Services.FileService.CreateStyleSheetFolder(virtualPath);
|
||||
break;
|
||||
|
||||
@@ -250,23 +250,23 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
case Core.Constants.Trees.PartialViews:
|
||||
codeFileDisplay = Mapper.Map<IPartialView, CodeFileDisplay>(new PartialView(PartialViewType.PartialView, string.Empty));
|
||||
codeFileDisplay.VirtualPath = SystemDirectories.PartialViews;
|
||||
codeFileDisplay.VirtualPath = Current.SystemDirectories.PartialViews;
|
||||
if (snippetName.IsNullOrWhiteSpace() == false)
|
||||
codeFileDisplay.Content = Services.FileService.GetPartialViewSnippetContent(snippetName);
|
||||
break;
|
||||
case Core.Constants.Trees.PartialViewMacros:
|
||||
codeFileDisplay = Mapper.Map<IPartialView, CodeFileDisplay>(new PartialView(PartialViewType.PartialViewMacro, string.Empty));
|
||||
codeFileDisplay.VirtualPath = SystemDirectories.MacroPartials;
|
||||
codeFileDisplay.VirtualPath = Current.SystemDirectories.MacroPartials;
|
||||
if (snippetName.IsNullOrWhiteSpace() == false)
|
||||
codeFileDisplay.Content = Services.FileService.GetPartialViewMacroSnippetContent(snippetName);
|
||||
break;
|
||||
case Core.Constants.Trees.Scripts:
|
||||
codeFileDisplay = Mapper.Map<Script, CodeFileDisplay>(new Script(string.Empty));
|
||||
codeFileDisplay.VirtualPath = SystemDirectories.Scripts;
|
||||
codeFileDisplay.VirtualPath = Current.SystemDirectories.Scripts;
|
||||
break;
|
||||
case Core.Constants.Trees.Stylesheets:
|
||||
codeFileDisplay = Mapper.Map<Stylesheet, CodeFileDisplay>(new Stylesheet(string.Empty));
|
||||
codeFileDisplay.VirtualPath = SystemDirectories.Css;
|
||||
codeFileDisplay.VirtualPath = Current.SystemDirectories.Css;
|
||||
break;
|
||||
default:
|
||||
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Unsupported editortype"));
|
||||
@@ -305,7 +305,7 @@ namespace Umbraco.Web.Editors
|
||||
switch (type)
|
||||
{
|
||||
case Core.Constants.Trees.PartialViews:
|
||||
if (IsDirectory(virtualPath, SystemDirectories.PartialViews))
|
||||
if (IsDirectory(virtualPath, Current.SystemDirectories.PartialViews))
|
||||
{
|
||||
Services.FileService.DeletePartialViewFolder(virtualPath);
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
@@ -317,7 +317,7 @@ namespace Umbraco.Web.Editors
|
||||
return Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Partial View or folder found with the specified path");
|
||||
|
||||
case Core.Constants.Trees.PartialViewMacros:
|
||||
if (IsDirectory(virtualPath, SystemDirectories.MacroPartials))
|
||||
if (IsDirectory(virtualPath, Current.SystemDirectories.MacroPartials))
|
||||
{
|
||||
Services.FileService.DeletePartialViewMacroFolder(virtualPath);
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
@@ -329,7 +329,7 @@ namespace Umbraco.Web.Editors
|
||||
return Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Partial View Macro or folder found with the specified path");
|
||||
|
||||
case Core.Constants.Trees.Scripts:
|
||||
if (IsDirectory(virtualPath, SystemDirectories.Scripts))
|
||||
if (IsDirectory(virtualPath, Current.SystemDirectories.Scripts))
|
||||
{
|
||||
Services.FileService.DeleteScriptFolder(virtualPath);
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
@@ -342,7 +342,7 @@ namespace Umbraco.Web.Editors
|
||||
return Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Script or folder found with the specified path");
|
||||
|
||||
case Core.Constants.Trees.Stylesheets:
|
||||
if (IsDirectory(virtualPath, SystemDirectories.Css))
|
||||
if (IsDirectory(virtualPath, Current.SystemDirectories.Css))
|
||||
{
|
||||
Services.FileService.DeleteStyleSheetFolder(virtualPath);
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
@@ -561,13 +561,13 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
private Attempt<IPartialView> CreateOrUpdatePartialView(CodeFileDisplay display)
|
||||
{
|
||||
return CreateOrUpdatePartialView(display, SystemDirectories.PartialViews,
|
||||
return CreateOrUpdatePartialView(display, Current.SystemDirectories.PartialViews,
|
||||
Services.FileService.GetPartialView, Services.FileService.SavePartialView, Services.FileService.CreatePartialView);
|
||||
}
|
||||
|
||||
private Attempt<IPartialView> CreateOrUpdatePartialViewMacro(CodeFileDisplay display)
|
||||
{
|
||||
return CreateOrUpdatePartialView(display, SystemDirectories.MacroPartials,
|
||||
return CreateOrUpdatePartialView(display, Current.SystemDirectories.MacroPartials,
|
||||
Services.FileService.GetPartialViewMacro, Services.FileService.SavePartialViewMacro, Services.FileService.CreatePartialViewMacro);
|
||||
}
|
||||
|
||||
|
||||
@@ -515,7 +515,7 @@ namespace Umbraco.Web.Editors
|
||||
[HttpPost]
|
||||
public HttpResponseMessage Import(string file)
|
||||
{
|
||||
var filePath = Path.Combine(Current.IOHelper.MapPath(SystemDirectories.Data), file);
|
||||
var filePath = Path.Combine(Current.IOHelper.MapPath(Current.SystemDirectories.Data), file);
|
||||
if (string.IsNullOrEmpty(file) || !System.IO.File.Exists(filePath))
|
||||
{
|
||||
return Request.CreateResponse(HttpStatusCode.NotFound);
|
||||
@@ -553,7 +553,7 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
|
||||
}
|
||||
|
||||
var root = Current.IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "FileUploads");
|
||||
var root = Current.IOHelper.MapPath(Current.SystemDirectories.TempData.EnsureEndsWith('/') + "FileUploads");
|
||||
//ensure it exists
|
||||
Directory.CreateDirectory(root);
|
||||
var provider = new MultipartFormDataStreamProvider(root);
|
||||
|
||||
@@ -311,12 +311,12 @@ namespace Umbraco.Web.Editors
|
||||
/// </returns>
|
||||
private IEnumerable<string> FindPartialViewFilesInViewsFolder()
|
||||
{
|
||||
var partialsDir = Current.IOHelper.MapPath(SystemDirectories.MacroPartials);
|
||||
var partialsDir = Current.IOHelper.MapPath(Current.SystemDirectories.MacroPartials);
|
||||
|
||||
return this.FindPartialViewFilesInFolder(
|
||||
partialsDir,
|
||||
partialsDir,
|
||||
SystemDirectories.MacroPartials);
|
||||
Current.SystemDirectories.MacroPartials);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -329,7 +329,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
var files = new List<string>();
|
||||
|
||||
var appPluginsFolder = new DirectoryInfo(Current.IOHelper.MapPath(SystemDirectories.AppPlugins));
|
||||
var appPluginsFolder = new DirectoryInfo(Current.IOHelper.MapPath(Current.SystemDirectories.AppPlugins));
|
||||
|
||||
if (!appPluginsFolder.Exists)
|
||||
{
|
||||
@@ -344,7 +344,7 @@ namespace Umbraco.Web.Editors
|
||||
var macroPartials = viewsFolder.First().GetDirectories("MacroPartials");
|
||||
if (macroPartials.Any())
|
||||
{
|
||||
files.AddRange(this.FindPartialViewFilesInFolder(macroPartials.First().FullName, macroPartials.First().FullName, SystemDirectories.AppPlugins + "/" + directory.Name + "/Views/MacroPartials"));
|
||||
files.AddRange(this.FindPartialViewFilesInFolder(macroPartials.First().FullName, macroPartials.First().FullName, Current.SystemDirectories.AppPlugins + "/" + directory.Name + "/Views/MacroPartials"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,7 +620,7 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
|
||||
}
|
||||
|
||||
var root = Current.IOHelper.MapPath(SystemDirectories.TempFileUploads);
|
||||
var root = Current.IOHelper.MapPath(Current.SystemDirectories.TempFileUploads);
|
||||
//ensure it exists
|
||||
Directory.CreateDirectory(root);
|
||||
var provider = new MultipartFormDataStreamProvider(root);
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
private void PopulateFromPackageData(LocalPackageInstallModel model)
|
||||
{
|
||||
var zipFile = new FileInfo(Path.Combine(Current.IOHelper.MapPath(SystemDirectories.Packages), model.ZipFileName));
|
||||
var zipFile = new FileInfo(Path.Combine(Current.IOHelper.MapPath(Current.SystemDirectories.Packages), model.ZipFileName));
|
||||
|
||||
var ins = Services.PackagingService.GetCompiledPackageInfo(zipFile);
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Umbraco.Web.Editors
|
||||
if (Request.Content.IsMimeMultipartContent() == false)
|
||||
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
|
||||
|
||||
var root = Current.IOHelper.MapPath(SystemDirectories.TempFileUploads);
|
||||
var root = Current.IOHelper.MapPath(Current.SystemDirectories.TempFileUploads);
|
||||
//ensure it exists
|
||||
Directory.CreateDirectory(root);
|
||||
var provider = new MultipartFormDataStreamProvider(root);
|
||||
@@ -159,7 +159,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
//we always save package files to /App_Data/packages/package-guid.umb for processing as a standard so lets copy.
|
||||
|
||||
var packagesFolder = Current.IOHelper.MapPath(SystemDirectories.Packages);
|
||||
var packagesFolder = Current.IOHelper.MapPath(Current.SystemDirectories.Packages);
|
||||
Directory.CreateDirectory(packagesFolder);
|
||||
var packageFile = Path.Combine(packagesFolder, model.PackageGuid + ".umb");
|
||||
File.Copy(file.LocalFileName, packageFile);
|
||||
@@ -211,7 +211,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
//Default path
|
||||
string fileName = packageGuid + ".umb";
|
||||
if (File.Exists(Path.Combine(Current.IOHelper.MapPath(SystemDirectories.Packages), fileName)) == false)
|
||||
if (File.Exists(Path.Combine(Current.IOHelper.MapPath(Current.SystemDirectories.Packages), fileName)) == false)
|
||||
{
|
||||
var packageFile = await Services.PackagingService.FetchPackageFileAsync(
|
||||
Guid.Parse(packageGuid),
|
||||
@@ -251,7 +251,7 @@ namespace Umbraco.Web.Editors
|
||||
[HttpPost]
|
||||
public PackageInstallModel Import(PackageInstallModel model)
|
||||
{
|
||||
var zipFile = new FileInfo(Path.Combine(Current.IOHelper.MapPath(SystemDirectories.Packages), model.ZipFileName));
|
||||
var zipFile = new FileInfo(Path.Combine(Current.IOHelper.MapPath(Current.SystemDirectories.Packages), model.ZipFileName));
|
||||
|
||||
var packageInfo = Services.PackagingService.GetCompiledPackageInfo(zipFile);
|
||||
|
||||
|
||||
@@ -45,10 +45,10 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
// Create an unique folder path to help with concurrent users to avoid filename clash
|
||||
var imageTempPath = Current.IOHelper.MapPath(SystemDirectories.TempImageUploads + "/" + Guid.NewGuid().ToString());
|
||||
var imageTempPath = Current.IOHelper.MapPath(Current.SystemDirectories.TempImageUploads + "/" + Guid.NewGuid().ToString());
|
||||
|
||||
// Temp folderpath (Files come in as bodypart & will need to move/saved into imgTempPath
|
||||
var folderPath = Current.IOHelper.MapPath(SystemDirectories.TempFileUploads);
|
||||
var folderPath = Current.IOHelper.MapPath(Current.SystemDirectories.TempFileUploads);
|
||||
|
||||
// Ensure image temp path exists
|
||||
if(Directory.Exists(imageTempPath) == false)
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Web.Editors
|
||||
var nonPluginFilters = _filters.Where(x => x.PluginName == null).ToList();
|
||||
|
||||
//add core tour files
|
||||
var coreToursPath = Path.Combine(Current.IOHelper.MapPath(SystemDirectories.Config), "BackOfficeTours");
|
||||
var coreToursPath = Path.Combine(Current.IOHelper.MapPath(Current.SystemDirectories.Config), "BackOfficeTours");
|
||||
if (Directory.Exists(coreToursPath))
|
||||
{
|
||||
foreach (var tourFile in Directory.EnumerateFiles(coreToursPath, "*.json"))
|
||||
@@ -51,7 +51,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
//collect all tour files in packages
|
||||
var appPlugins = Current.IOHelper.MapPath(SystemDirectories.AppPlugins);
|
||||
var appPlugins = Current.IOHelper.MapPath(Current.SystemDirectories.AppPlugins);
|
||||
if (Directory.Exists(appPlugins))
|
||||
{
|
||||
foreach (var plugin in Directory.EnumerateDirectories(appPlugins))
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
|
||||
}
|
||||
|
||||
var root = Current.IOHelper.MapPath(SystemDirectories.TempFileUploads);
|
||||
var root = Current.IOHelper.MapPath(Current.SystemDirectories.TempFileUploads);
|
||||
//ensure it exists
|
||||
Directory.CreateDirectory(root);
|
||||
var provider = new MultipartFormDataStreamProvider(root);
|
||||
|
||||
@@ -60,24 +60,24 @@ namespace Umbraco.Web.HealthCheck.Checks.Permissions
|
||||
// in ALL circumstances or just some
|
||||
var pathsToCheck = new Dictionary<string, PermissionCheckRequirement>
|
||||
{
|
||||
{ SystemDirectories.Data, PermissionCheckRequirement.Required },
|
||||
{ SystemDirectories.Packages, PermissionCheckRequirement.Required},
|
||||
{ SystemDirectories.Preview, PermissionCheckRequirement.Required },
|
||||
{ SystemDirectories.AppPlugins, PermissionCheckRequirement.Required },
|
||||
{ SystemDirectories.Config, PermissionCheckRequirement.Optional },
|
||||
{ SystemDirectories.Css, PermissionCheckRequirement.Optional },
|
||||
{ SystemDirectories.Media, PermissionCheckRequirement.Optional },
|
||||
{ SystemDirectories.Scripts, PermissionCheckRequirement.Optional },
|
||||
{ SystemDirectories.Umbraco, PermissionCheckRequirement.Optional },
|
||||
{ SystemDirectories.MvcViews, PermissionCheckRequirement.Optional }
|
||||
{ Current.SystemDirectories.Data, PermissionCheckRequirement.Required },
|
||||
{ Current.SystemDirectories.Packages, PermissionCheckRequirement.Required},
|
||||
{ Current.SystemDirectories.Preview, PermissionCheckRequirement.Required },
|
||||
{ Current.SystemDirectories.AppPlugins, PermissionCheckRequirement.Required },
|
||||
{ Current.SystemDirectories.Config, PermissionCheckRequirement.Optional },
|
||||
{ Current.SystemDirectories.Css, PermissionCheckRequirement.Optional },
|
||||
{ Current.SystemDirectories.Media, PermissionCheckRequirement.Optional },
|
||||
{ Current.SystemDirectories.Scripts, PermissionCheckRequirement.Optional },
|
||||
{ Current.SystemDirectories.Umbraco, PermissionCheckRequirement.Optional },
|
||||
{ Current.SystemDirectories.MvcViews, PermissionCheckRequirement.Optional }
|
||||
};
|
||||
|
||||
//These are special paths to check that will restart an app domain if a file is written to them,
|
||||
//so these need to be tested differently
|
||||
var pathsToCheckWithRestarts = new Dictionary<string, PermissionCheckRequirement>
|
||||
{
|
||||
{ SystemDirectories.AppCode, PermissionCheckRequirement.Optional },
|
||||
{ SystemDirectories.Bin, PermissionCheckRequirement.Optional }
|
||||
{ Current.SystemDirectories.AppCode, PermissionCheckRequirement.Optional },
|
||||
{ Current.SystemDirectories.Bin, PermissionCheckRequirement.Optional }
|
||||
};
|
||||
|
||||
// Run checks for required and optional paths for modify permission
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Umbraco.Web
|
||||
{
|
||||
var htmlBadge =
|
||||
String.Format(Current.Configs.Settings().Content.PreviewBadge,
|
||||
Current.IOHelper.ResolveUrl(SystemDirectories.Umbraco),
|
||||
Current.IOHelper.ResolveUrl(Current.SystemDirectories.Umbraco),
|
||||
Current.UmbracoContext.HttpContext.Server.UrlEncode(Current.UmbracoContext.HttpContext.Request.Path));
|
||||
return new MvcHtmlString(htmlBadge);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Web.Install.Controllers
|
||||
public ActionResult Index()
|
||||
{
|
||||
if (_runtime.Level == RuntimeLevel.Run)
|
||||
return Redirect(SystemDirectories.Umbraco.EnsureEndsWith('/'));
|
||||
return Redirect(Current.SystemDirectories.Umbraco.EnsureEndsWith('/'));
|
||||
|
||||
if (_runtime.Level == RuntimeLevel.Upgrade)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ namespace Umbraco.Web.Install.Controllers
|
||||
{
|
||||
case ValidateRequestAttempt.FailedNoPrivileges:
|
||||
case ValidateRequestAttempt.FailedNoContextId:
|
||||
return Redirect(SystemDirectories.Umbraco + "/AuthorizeUpgrade?redir=" + Server.UrlEncode(Request.RawUrl));
|
||||
return Redirect(Current.SystemDirectories.Umbraco + "/AuthorizeUpgrade?redir=" + Server.UrlEncode(Request.RawUrl));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Umbraco.Web.Install.Controllers
|
||||
ViewData.SetInstallApiBaseUrl(Url.GetUmbracoApiService("GetSetup", "InstallApi", "UmbracoInstall").TrimEnd("GetSetup"));
|
||||
|
||||
// get the base umbraco folder
|
||||
ViewData.SetUmbracoBaseFolder(Current.IOHelper.ResolveUrl(SystemDirectories.Umbraco));
|
||||
ViewData.SetUmbracoBaseFolder(Current.IOHelper.ResolveUrl(Current.SystemDirectories.Umbraco));
|
||||
|
||||
_installHelper.InstallStatus(false, "");
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Umbraco.Web.Install
|
||||
internal class FilePermissionHelper
|
||||
{
|
||||
// ensure that these directories exist and Umbraco can write to them
|
||||
private static readonly string[] PermissionDirs = { SystemDirectories.Css, SystemDirectories.Config, SystemDirectories.Data, SystemDirectories.Media, SystemDirectories.Preview };
|
||||
private static readonly string[] PackagesPermissionsDirs = { SystemDirectories.Bin, SystemDirectories.Umbraco, SystemDirectories.Packages };
|
||||
private static readonly string[] PermissionDirs = { Current.SystemDirectories.Css, Current.SystemDirectories.Config, Current.SystemDirectories.Data, Current.SystemDirectories.Media, Current.SystemDirectories.Preview };
|
||||
private static readonly string[] PackagesPermissionsDirs = { Current.SystemDirectories.Bin, Current.SystemDirectories.Umbraco, Current.SystemDirectories.Packages };
|
||||
|
||||
// ensure Umbraco can write to these files (the directories must exist)
|
||||
private static readonly string[] PermissionFiles = { };
|
||||
@@ -35,7 +35,7 @@ namespace Umbraco.Web.Install
|
||||
if (TestPublishedSnapshotService(out errors) == false)
|
||||
report["Published snapshot environment check failed"] = errors.ToList();
|
||||
|
||||
if (EnsureCanCreateSubDirectory(SystemDirectories.Media, out errors) == false)
|
||||
if (EnsureCanCreateSubDirectory(Current.SystemDirectories.Media, out errors) == false)
|
||||
report["Media folder creation failed"] = errors.ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Umbraco.Web.Install
|
||||
/// <param name="filterContext"></param>
|
||||
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
|
||||
{
|
||||
filterContext.Result = new RedirectResult(SystemDirectories.Umbraco.EnsureEndsWith('/'));
|
||||
filterContext.Result = new RedirectResult(Current.SystemDirectories.Umbraco.EnsureEndsWith('/'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace Umbraco.Web.Install
|
||||
|
||||
private static string GetFile(Guid installId)
|
||||
{
|
||||
var file = Current.IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "Install/"
|
||||
+ "install_"
|
||||
+ installId.ToString("N")
|
||||
+ ".txt");
|
||||
var file = Current.IOHelper.MapPath(Current.SystemDirectories.TempData.EnsureEndsWith('/') + "Install/"
|
||||
+ "install_"
|
||||
+ installId.ToString("N")
|
||||
+ ".txt");
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Umbraco.Web.Install
|
||||
|
||||
public static void ClearFiles()
|
||||
{
|
||||
var dir = Current.IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "Install/");
|
||||
var dir = Current.IOHelper.MapPath(Current.SystemDirectories.TempData.EnsureEndsWith('/') + "Install/");
|
||||
if (Directory.Exists(dir))
|
||||
{
|
||||
var files = Directory.GetFiles(dir);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
if (model.HasValue && model.Value == false) return Task.FromResult<InstallSetupResult>(null);
|
||||
|
||||
//install the machine key
|
||||
var fileName = Current.IOHelper.MapPath($"{SystemDirectories.Root}/web.config");
|
||||
var fileName = Current.IOHelper.MapPath($"{Current.SystemDirectories.Root}/web.config");
|
||||
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
|
||||
|
||||
// we only want to get the element that is under the root, (there may be more under <location> tags we don't want them)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
|
||||
private void CleanupInstallation(int packageId, string packageFile)
|
||||
{
|
||||
var zipFile = new FileInfo(Path.Combine(Current.IOHelper.MapPath(SystemDirectories.Packages), HttpUtility.UrlDecode(packageFile)));
|
||||
var zipFile = new FileInfo(Path.Combine(Current.IOHelper.MapPath(Current.SystemDirectories.Packages), HttpUtility.UrlDecode(packageFile)));
|
||||
|
||||
if (zipFile.Exists)
|
||||
zipFile.Delete();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Web.JavaScript
|
||||
{
|
||||
if (logger == null) throw new ArgumentNullException("logger");
|
||||
_logger = logger;
|
||||
_fileName = Current.IOHelper.MapPath(string.Format("{0}/ClientDependency.config", SystemDirectories.Config));
|
||||
_fileName = Current.IOHelper.MapPath(string.Format("{0}/ClientDependency.config", Current.SystemDirectories.Config));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Umbraco.Web.JavaScript
|
||||
}
|
||||
jarray.Append("]");
|
||||
|
||||
return WriteScript(jarray.ToString(), Current.IOHelper.ResolveUrl(SystemDirectories.Umbraco), angularModule);
|
||||
return WriteScript(jarray.ToString(), Current.IOHelper.ResolveUrl(Current.SystemDirectories.Umbraco), angularModule);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Umbraco.Web.JavaScript
|
||||
public UmbracoClientDependencyLoader()
|
||||
: base()
|
||||
{
|
||||
this.AddPath("UmbracoRoot", Current.IOHelper.ResolveUrl(SystemDirectories.Umbraco));
|
||||
this.AddPath("UmbracoRoot", Current.IOHelper.ResolveUrl(Current.SystemDirectories.Umbraco));
|
||||
this.ProviderName = LoaderControlProvider.DefaultName;
|
||||
|
||||
}
|
||||
|
||||
@@ -35,16 +35,16 @@ namespace Umbraco.Web.Mvc
|
||||
|
||||
var viewLocationsArray = new[]
|
||||
{
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/{1}/{0}.cshtml"),
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/{1}/{0}.vbhtml")
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/{1}/{0}.cshtml"),
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/{1}/{0}.vbhtml")
|
||||
};
|
||||
|
||||
//set all of the area view locations to the plugin folder
|
||||
AreaViewLocationFormats = viewLocationsArray
|
||||
.Concat(new[]
|
||||
{
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/Shared/{0}.cshtml"),
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/Shared/{0}.vbhtml")
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/Shared/{0}.cshtml"),
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/Shared/{0}.vbhtml")
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
@@ -53,15 +53,15 @@ namespace Umbraco.Web.Mvc
|
||||
AreaPartialViewLocationFormats = new[]
|
||||
{
|
||||
//will be used when we have partial view and child action macros
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/Partials/{0}.cshtml"),
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/Partials/{0}.vbhtml"),
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/MacroPartials/{0}.cshtml"),
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/MacroPartials/{0}.vbhtml"),
|
||||
//for partials
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/{1}/{0}.cshtml"),
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/{1}/{0}.vbhtml"),
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/Shared/{0}.cshtml"),
|
||||
string.Concat(SystemDirectories.AppPlugins, "/{2}/Views/Shared/{0}.vbhtml")
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/Partials/{0}.cshtml"),
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/Partials/{0}.vbhtml"),
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/MacroPartials/{0}.cshtml"),
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/MacroPartials/{0}.vbhtml"),
|
||||
//for partialsCurrent.
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/{1}/{0}.cshtml"),
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/{1}/{0}.vbhtml"),
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/Shared/{0}.cshtml"),
|
||||
string.Concat(Current.SystemDirectories.AppPlugins, "/{2}/Views/Shared/{0}.vbhtml")
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ namespace Umbraco.Web.Mvc
|
||||
// creating previewBadge markup
|
||||
markupToInject =
|
||||
string.Format(Current.Configs.Settings().Content.PreviewBadge,
|
||||
Current.IOHelper.ResolveUrl(SystemDirectories.Umbraco),
|
||||
Current.IOHelper.ResolveUrl(Current.SystemDirectories.Umbraco),
|
||||
Server.UrlEncode(Current.UmbracoContext.HttpContext.Request.Url?.PathAndQuery));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Umbraco.Web.Runtime
|
||||
private static void ConfigureClientDependency(IGlobalSettings globalSettings)
|
||||
{
|
||||
// Backwards compatibility - set the path and URL type for ClientDependency 1.5.1 [LK]
|
||||
XmlFileMapper.FileMapDefaultFolder = SystemDirectories.TempData.EnsureEndsWith('/') + "ClientDependency";
|
||||
XmlFileMapper.FileMapDefaultFolder = Current.SystemDirectories.TempData.EnsureEndsWith('/') + "ClientDependency";
|
||||
BaseCompositeFileProcessingProvider.UrlTypeDefault = CompositeUrlType.Base64QueryStrings;
|
||||
|
||||
// Now we need to detect if we are running 'Umbraco.Core.LocalTempStorage' as EnvironmentTemp and in that case we want to change the CDF file
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Umbraco.Web.Scheduling
|
||||
// temp file cleanup, will run on all servers - even though file upload should only be handled on the master, this will
|
||||
// ensure that in the case it happes on replicas that they are cleaned up.
|
||||
var task = new TempFileCleanup(_fileCleanupRunner, DefaultDelayMilliseconds, OneHourMilliseconds,
|
||||
new[] { new DirectoryInfo(Current.IOHelper.MapPath(SystemDirectories.TempFileUploads)) },
|
||||
new[] { new DirectoryInfo(Current.IOHelper.MapPath(Current.SystemDirectories.TempFileUploads)) },
|
||||
TimeSpan.FromDays(1), //files that are over a day old
|
||||
_runtime, _logger);
|
||||
_scrubberRunner.TryAdd(task);
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace Umbraco.Web.Security
|
||||
|
||||
private static bool RequestIsInUmbracoApplication(HttpContextBase context)
|
||||
{
|
||||
return context.Request.Path.ToLower().IndexOf(Current.IOHelper.ResolveUrl(SystemDirectories.Umbraco).ToLower(), StringComparison.Ordinal) > -1;
|
||||
return context.Request.Path.ToLower().IndexOf(Current.IOHelper.ResolveUrl(Current.SystemDirectories.Umbraco).ToLower(), StringComparison.Ordinal) > -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace Umbraco.Web
|
||||
return Attempt.If(reason == EnsureRoutableOutcome.IsRoutable, reason);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private bool EnsureRuntime(HttpContextBase httpContext, Uri uri)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ namespace Umbraco.Web
|
||||
case RuntimeLevel.Upgrade:
|
||||
// redirect to install
|
||||
ReportRuntime(level, "Umbraco must install or upgrade.");
|
||||
var installPath = UriUtility.ToAbsolute(SystemDirectories.Install);
|
||||
var installPath = UriUtility.ToAbsolute(Current.SystemDirectories.Install);
|
||||
var installUrl = $"{installPath}/?redir=true&url={HttpUtility.UrlEncode(uri.ToString())}";
|
||||
httpContext.Response.Redirect(installUrl, true);
|
||||
return false; // cannot serve content
|
||||
@@ -436,6 +436,6 @@ namespace Umbraco.Web
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user