Merge remote-tracking branch 'origin/temp8' into temp8-3708

This commit is contained in:
Shannon
2019-01-09 13:19:40 +11:00
8 changed files with 94 additions and 51 deletions

View File

@@ -22,7 +22,7 @@
not want this to happen as the alpha of the next major is, really, the next major already.
-->
<dependency id="Microsoft.AspNet.SignalR.Core" version="[2.2.3, 2.999999)" />
<dependency id="Umbraco.ModelsBuilder.Ui" version="[8.0.0-alpha.26]" />
<dependency id="Umbraco.ModelsBuilder.Ui" version="[8.0.0-alpha.29]" />
<dependency id="ImageProcessor.Web" version="[4.9.3.25,4.999999)" />
<dependency id="ImageProcessor.Web.Config" version="[2.4.1.19,2.999999)" />
<dependency id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="[2.0.1,2.999999)" />

View File

@@ -65,5 +65,33 @@ namespace Umbraco.Core.IO
}
fs.DeleteFile(tempFile);
}
/// <summary>
/// Unwraps a filesystem.
/// </summary>
/// <remarks>
/// <para>A filesystem can be wrapped in a <see cref="FileSystemWrapper"/> (public) or a <see cref="ShadowWrapper"/> (internal),
/// and this method deals with the various wrappers and </para>
/// </remarks>
public static IFileSystem Unwrap(this IFileSystem filesystem)
{
var unwrapping = true;
while (unwrapping)
{
switch (filesystem)
{
case FileSystemWrapper wrapper:
filesystem = wrapper.InnerFileSystem;
break;
case ShadowWrapper shadow:
filesystem = shadow.InnerFileSystem;
break;
default:
unwrapping = false;
break;
}
}
return filesystem;
}
}
}

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Core.IO
InnerFileSystem = innerFileSystem;
}
public IFileSystem InnerFileSystem { get; internal set; }
internal IFileSystem InnerFileSystem { get; set; }
public IEnumerable<string> GetDirectories(string path)
{

View File

@@ -75,6 +75,8 @@ namespace Umbraco.Core.IO
}
}
public IFileSystem InnerFileSystem => _innerFileSystem;
private IFileSystem FileSystem
{
get

View File

@@ -86,6 +86,16 @@ namespace Umbraco.Tests.IO
Assert.AreSame(fileSystem1, fileSystem2);
}
[Test]
public void Can_Unwrap_MediaFileSystem()
{
var fileSystem = _factory.GetInstance<IMediaFileSystem>();
var unwrapped = fileSystem.Unwrap();
Assert.IsNotNull(unwrapped);
var physical = unwrapped as PhysicalFileSystem;
Assert.IsNotNull(physical);
}
[Test]
public void Can_Delete_MediaFiles()
{

View File

@@ -0,0 +1,6 @@
angular.module('umbraco.filters')
.filter('safe_html', ['$sce', function($sce){
return function(text) {
return $sce.trustAsHtml(text);
};
}]);

View File

@@ -19,7 +19,7 @@
<!-- Controls -->
<div ng-repeat="control in area.controls" class="dash-control dash-control-{{control.alias}}">
<div class="dash-inner-control">
<div ng-bind-html="control.html"></div>
<div ng-bind-html="control.html | safe_html"></div>
</div>
</div>
<!-- Controls end -->
@@ -65,7 +65,7 @@
</div>
</div>
</div>
</div>
</div>

View File

@@ -4,7 +4,6 @@ using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using System.Web.Hosting;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Events;
using Umbraco.Core.Logging;
@@ -15,7 +14,43 @@ namespace Umbraco.Web.Scheduling
/// </summary>
/// <remarks>This class exists for logging purposes - the one you want to use is BackgroundTaskRunner{T}.</remarks>
public abstract class BackgroundTaskRunner
{ }
{
/// <summary>
/// Creates a hook, to hook the task runner into the main domain.
/// </summary>
/// <param name="mainDom">The <see cref="IMainDom"/> object.</param>
/// <param name="install">A method to execute when hooking into the main domain.</param>
/// <param name="release">A method to execute when the main domain releases.</param>
/// <returns></returns>
public MainDomHook CreateMainDomHook(IMainDom mainDom, Action install, Action release)
{
return new MainDomHook(mainDom, install, release);
}
public class MainDomHook
{
public MainDomHook(IMainDom mainDom, Action install, Action release)
{
MainDom = mainDom;
Install = install;
Release = release;
}
public IMainDom MainDom { get; }
public Action Install { get; }
public Action Release { get; }
internal bool Register()
{
if (MainDom != null)
return MainDom.Register(Install, Release);
// tests
Install?.Invoke();
return true;
}
}
}
/// <summary>
/// Manages a queue of tasks of type <typeparamref name="T"/> and runs them in the background.
@@ -55,42 +90,6 @@ namespace Umbraco.Web.Scheduling
private bool _terminated; // remember we've terminated
private readonly TaskCompletionSource<int> _terminatedSource = new TaskCompletionSource<int>(); // enable awaiting termination
// fixme - this is temp
// at the moment MainDom is internal so we have to find a way to hook into it - temp
public class MainDomHook
{
private MainDomHook(MainDom mainDom, Action install, Action release)
{
MainDom = mainDom;
Install = install;
Release = release;
}
internal MainDom MainDom { get; }
public Action Install { get; }
public Action Release { get; }
public static MainDomHook Create(Action install, Action release)
{
return new MainDomHook(Core.Composing.Current.Factory.GetInstance<MainDom>(), install, release);
}
public static MainDomHook CreateForTest(Action install, Action release)
{
return new MainDomHook(null, install, release);
}
public bool Register()
{
if (MainDom != null)
return MainDom.Register(Install, Release);
// tests
Install?.Invoke();
return true;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="BackgroundTaskRunner{T}"/> class.
/// </summary>
@@ -129,11 +128,9 @@ namespace Umbraco.Web.Scheduling
/// <param name="hook">An optional main domain hook.</param>
public BackgroundTaskRunner(string name, BackgroundTaskRunnerOptions options, ILogger logger, MainDomHook hook = null)
{
if (options == null) throw new ArgumentNullException(nameof(options));
if (logger == null) throw new ArgumentNullException(nameof(logger));
_options = options;
_options = options ?? throw new ArgumentNullException(nameof(options));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_logPrefix = "[" + name + "] ";
_logger = logger;
if (options.Hosted)
HostingEnvironment.RegisterObject(this);
@@ -319,7 +316,7 @@ namespace Umbraco.Web.Scheduling
}
/// <summary>
/// Shuts the taks runner down.
/// Shuts the tasks runner down.
/// </summary>
/// <param name="force">True for force the runner to stop.</param>
/// <param name="wait">True to wait until the runner has stopped.</param>
@@ -355,7 +352,7 @@ namespace Umbraco.Web.Scheduling
// tasks in the queue will be executed...
if (wait == false) return;
_runningTask?.Wait(); // wait for whatever is running to end...
_runningTask?.Wait(CancellationToken.None); // wait for whatever is running to end...
}
private async Task Pump()
@@ -648,13 +645,13 @@ namespace Umbraco.Web.Scheduling
#endregion
/// <summary>
/// Requests a registered object to unregister.
/// Requests a registered object to un-register.
/// </summary>
/// <param name="immediate">true to indicate the registered object should unregister from the hosting
/// <param name="immediate">true to indicate the registered object should un-register from the hosting
/// environment before returning; otherwise, false.</param>
/// <remarks>
/// <para>"When the application manager needs to stop a registered object, it will call the Stop method."</para>
/// <para>The application manager will call the Stop method to ask a registered object to unregister. During
/// <para>The application manager will call the Stop method to ask a registered object to un-register. During
/// processing of the Stop method, the registered object must call the HostingEnvironment.UnregisterObject method.</para>
/// </remarks>
public void Stop(bool immediate)