Merge remote-tracking branch 'origin/netcore/dev' into netcore/feature/executable-backoffice
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
namespace Umbraco.Web.Features
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a marker interface to allow controllers to be disabled if also marked with FeatureAuthorizeAttribute.
|
||||
/// </summary>
|
||||
public interface IUmbracoFeature
|
||||
{
|
||||
|
||||
|
||||
@@ -75,5 +75,6 @@ namespace Umbraco.Core.IO
|
||||
get;
|
||||
set; //Only required for unit tests
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -1,17 +1,17 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Web.Install
|
||||
namespace Umbraco.Core.IO
|
||||
{
|
||||
public class FilePermissionDirectoryHelper
|
||||
public static class IOHelperExtensions
|
||||
{
|
||||
|
||||
|
||||
// tries to create a file
|
||||
// if successful, the file is deleted
|
||||
// creates the directory if needed - does not delete it
|
||||
public static bool TryCreateDirectory(string dir, IIOHelper ioHelper)
|
||||
/// <summary>
|
||||
/// Tries to create a directory.
|
||||
/// </summary>
|
||||
/// <param name="ioHelper">The IOHelper.</param>
|
||||
/// <param name="dir">the directory path.</param>
|
||||
/// <returns>true if the directory was created, false otherwise.</returns>
|
||||
public static bool TryCreateDirectory(this IIOHelper ioHelper, string dir)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -20,7 +20,7 @@ namespace Umbraco.Web.Install
|
||||
if (Directory.Exists(dirPath) == false)
|
||||
Directory.CreateDirectory(dirPath);
|
||||
|
||||
var filePath = dirPath + "/" + CreateRandomFileName() + ".tmp";
|
||||
var filePath = dirPath + "/" + CreateRandomFileName(ioHelper) + ".tmp";
|
||||
File.WriteAllText(filePath, "This is an Umbraco internal test file. It is safe to delete it.");
|
||||
File.Delete(filePath);
|
||||
return true;
|
||||
@@ -31,7 +31,7 @@ namespace Umbraco.Web.Install
|
||||
}
|
||||
}
|
||||
|
||||
public static string CreateRandomFileName()
|
||||
public static string CreateRandomFileName(this IIOHelper ioHelper)
|
||||
{
|
||||
return "umbraco-test." + Guid.NewGuid().ToString("N").Substring(0, 8);
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace Umbraco.Core.Sync
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IServerMessenger"/> implementation that works by storing messages in the database.
|
||||
/// </summary>
|
||||
public interface IBatchedDatabaseServerMessenger : IServerMessenger
|
||||
{
|
||||
void FlushBatch();
|
||||
|
||||
@@ -2,8 +2,16 @@ using Umbraco.Web.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Represents a factory to create <see cref="MenuItemCollection"/>.
|
||||
/// </summary>
|
||||
public interface IMenuItemCollectionFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an empty <see cref="MenuItemCollection"/>.
|
||||
/// </summary>
|
||||
/// <returns>An empty <see cref="MenuItemCollection"/>.</returns>
|
||||
MenuItemCollection Create();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
public interface IUmbracoRouteEventSender
|
||||
{
|
||||
event EventHandler<RoutableAttemptEventArgs> RouteAttempt;
|
||||
}
|
||||
}
|
||||
@@ -364,7 +364,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
public override bool EnsureEnvironment(out IEnumerable<string> errors)
|
||||
{
|
||||
// must have app_data and be able to write files into it
|
||||
var ok = FilePermissionDirectoryHelper.TryCreateDirectory(GetLocalFilesPath(), _ioHelper);
|
||||
var ok = _ioHelper.TryCreateDirectory(GetLocalFilesPath());
|
||||
errors = ok ? Enumerable.Empty<string>() : new[] { "NuCache local files." };
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,15 @@ namespace Umbraco.Web.Install.Controllers
|
||||
// determines whether the step requires execution
|
||||
internal bool StepRequiresExecution(InstallSetupStep step, object instruction)
|
||||
{
|
||||
var model = Convert.ChangeType(instruction, step.StepType);
|
||||
if (step == null) throw new ArgumentNullException(nameof(step));
|
||||
|
||||
var modelAttempt = instruction.TryConvertTo(step.StepType);
|
||||
if (!modelAttempt.Success)
|
||||
{
|
||||
throw new InvalidCastException($"Cannot cast/convert {step.GetType().FullName} into {step.StepType.FullName}");
|
||||
}
|
||||
|
||||
var model = modelAttempt.Result;
|
||||
var genericStepType = typeof(InstallSetupStep<>);
|
||||
Type[] typeArgs = { step.StepType };
|
||||
var typedStepType = genericStepType.MakeGenericType(typeArgs);
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace Umbraco.Web.Install
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = _ioHelper.MapPath(dir + "/" + FilePermissionDirectoryHelper.CreateRandomFileName());
|
||||
var path = _ioHelper.MapPath(dir + "/" + _ioHelper.CreateRandomFileName());
|
||||
Directory.CreateDirectory(path);
|
||||
Directory.Delete(path);
|
||||
return true;
|
||||
@@ -171,7 +171,7 @@ namespace Umbraco.Web.Install
|
||||
|
||||
if (canWrite)
|
||||
{
|
||||
var filePath = dirPath + "/" + FilePermissionDirectoryHelper.CreateRandomFileName() + ".tmp";
|
||||
var filePath = dirPath + "/" + _ioHelper.CreateRandomFileName() + ".tmp";
|
||||
File.WriteAllText(filePath, "This is an Umbraco internal test file. It is safe to delete it.");
|
||||
File.Delete(filePath);
|
||||
return true;
|
||||
|
||||
@@ -20,11 +20,9 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
public abstract class FileSystemTreeController : TreeController
|
||||
{
|
||||
private readonly IMenuItemCollectionFactory _menuItemCollectionFactory;
|
||||
|
||||
protected FileSystemTreeController()
|
||||
{
|
||||
_menuItemCollectionFactory = Current.MenuItemCollectionFactory;
|
||||
MenuItemCollectionFactory = Current.MenuItemCollectionFactory;
|
||||
}
|
||||
|
||||
protected FileSystemTreeController(
|
||||
@@ -41,10 +39,11 @@ namespace Umbraco.Web.Trees
|
||||
IMenuItemCollectionFactory menuItemCollectionFactory)
|
||||
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, umbracoMapper, publishedUrlProvider)
|
||||
{
|
||||
_menuItemCollectionFactory = menuItemCollectionFactory;
|
||||
MenuItemCollectionFactory = menuItemCollectionFactory;
|
||||
}
|
||||
|
||||
protected abstract IFileSystem FileSystem { get; }
|
||||
protected IMenuItemCollectionFactory MenuItemCollectionFactory { get; }
|
||||
protected abstract string[] Extensions { get; }
|
||||
protected abstract string FileIcon { get; }
|
||||
|
||||
@@ -120,7 +119,7 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
protected virtual MenuItemCollection GetMenuForRootNode(FormDataCollection queryStrings)
|
||||
{
|
||||
var menu = _menuItemCollectionFactory.Create();
|
||||
var menu = MenuItemCollectionFactory.Create();
|
||||
|
||||
//set the default to create
|
||||
menu.DefaultMenuAlias = ActionNew.ActionAlias;
|
||||
@@ -134,7 +133,7 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
protected virtual MenuItemCollection GetMenuForFolder(string path, FormDataCollection queryStrings)
|
||||
{
|
||||
var menu = _menuItemCollectionFactory.Create();
|
||||
var menu = MenuItemCollectionFactory.Create();
|
||||
|
||||
//set the default to create
|
||||
menu.DefaultMenuAlias = ActionNew.ActionAlias;
|
||||
@@ -158,7 +157,7 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
protected virtual MenuItemCollection GetMenuForFile(string path, FormDataCollection queryStrings)
|
||||
{
|
||||
var menu = _menuItemCollectionFactory.Create();
|
||||
var menu = MenuItemCollectionFactory.Create();
|
||||
|
||||
//if it's not a directory then we only allow to delete the item
|
||||
menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
|
||||
@@ -174,7 +173,7 @@ namespace Umbraco.Web.Trees
|
||||
return GetMenuForRootNode(queryStrings);
|
||||
}
|
||||
|
||||
var menu = _menuItemCollectionFactory.Create();
|
||||
var menu = MenuItemCollectionFactory.Create();
|
||||
|
||||
var path = string.IsNullOrEmpty(id) == false && id != Constants.System.RootString
|
||||
? HttpUtility.UrlDecode(id).TrimStart("/")
|
||||
|
||||
Reference in New Issue
Block a user