Creates RuntimeStateOptions and pre-loads the error page on the installer

This commit is contained in:
Shannon
2019-01-17 01:42:56 +11:00
parent c5da10cf10
commit 899bb812aa
4 changed files with 64 additions and 22 deletions

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Threading;
using System.Web;
using Semver;
@@ -133,11 +132,6 @@ namespace Umbraco.Core
/// <inheritdoc />
public BootFailedException BootFailedException { get; internal set; }
// currently configured via app settings
private static bool BoolSetting(string key, bool missing) => ConfigurationManager.AppSettings[key]?.InvariantEquals("true") ?? missing;
private bool InstallMissingDatabase { get; } = BoolSetting("Umbraco.Core.RuntimeState.InstallMissingDatabase", false);
private bool InstallEmptyDatabase { get; } = BoolSetting("Umbraco.Core.RuntimeState.InstallEmptyDatabase", false);
/// <summary>
/// Determines the runtime level.
/// </summary>
@@ -185,7 +179,7 @@ namespace Umbraco.Core
// else, keep going,
// anything other than install wants a database - see if we can connect
// (since this is an already existing database, assume localdb is ready)
var tries = InstallMissingDatabase ? 2 : 5;
var tries = RuntimeStateOptions.InstallMissingDatabase ? 2 : 5;
for (var i = 0;;)
{
connect = databaseFactory.CanConnect;
@@ -199,7 +193,7 @@ namespace Umbraco.Core
// cannot connect to configured database, this is bad, fail
logger.Debug<RuntimeState>("Could not connect to database.");
if (InstallMissingDatabase)
if (RuntimeStateOptions.InstallMissingDatabase)
{
// ok to install on a configured but missing database
Level = RuntimeLevel.Install;
@@ -228,7 +222,7 @@ namespace Umbraco.Core
// can connect to the database but cannot check the upgrade state... oops
logger.Warn<RuntimeState>(e, "Could not check the upgrade state.");
if (InstallEmptyDatabase)
if (RuntimeStateOptions.InstallEmptyDatabase)
{
// ok to install on an empty database
Level = RuntimeLevel.Install;

View File

@@ -0,0 +1,40 @@
using System.Configuration;
namespace Umbraco.Core
{
/// <summary>
/// Allows configuration of the <see cref="RuntimeState"/> in PreApplicationStart or in appSettings
/// </summary>
public static class RuntimeStateOptions
{
// configured statically or via app settings
private static bool BoolSetting(string key, bool missing) => ConfigurationManager.AppSettings[key]?.InvariantEquals("true") ?? missing;
/// <summary>
/// If true the RuntimeState will continue the installation sequence when a database is missing
/// </summary>
/// <remarks>
/// In this case it will be up to the implementor that is setting this value to true to take over the bootup/installation sequence
/// </remarks>
public static bool InstallMissingDatabase
{
get => _installEmptyDatabase ?? BoolSetting("Umbraco.Core.RuntimeState.InstallMissingDatabase", false);
set => _installEmptyDatabase = value;
}
/// <summary>
/// If true the RuntimeState will continue the installation sequence when a database is available but is empty
/// </summary>
/// <remarks>
/// In this case it will be up to the implementor that is setting this value to true to take over the bootup/installation sequence
/// </remarks>
public static bool InstallEmptyDatabase
{
get => _installMissingDatabase ?? BoolSetting("Umbraco.Core.RuntimeState.InstallEmptyDatabase", false);
set => _installMissingDatabase = value;
}
private static bool? _installMissingDatabase;
private static bool? _installEmptyDatabase;
}
}

View File

@@ -512,6 +512,7 @@
<Compile Include="ReadLock.cs" />
<Compile Include="ReflectionUtilities-Unused.cs" />
<Compile Include="RuntimeLevelReason.cs" />
<Compile Include="RuntimeStateOptions.cs" />
<Compile Include="Runtime\CoreRuntime.cs" />
<Compile Include="Runtime\CoreRuntimeComponent.cs" />
<Compile Include="CustomBooleanTypeConverter.cs" />

View File

@@ -1,4 +1,4 @@
angular.module("umbraco.install").factory('installerService', function($rootScope, $q, $timeout, $http, $location, $log){
angular.module("umbraco.install").factory('installerService', function ($rootScope, $q, $timeout, $http, $templateRequest){
var _status = {
index: 0,
@@ -106,19 +106,26 @@ angular.module("umbraco.install").factory('installerService', function($rootScop
//loads the needed steps and sets the intial state
init : function(){
service.status.loading = true;
if(!_status.all){
service.getSteps().then(function(response){
service.status.steps = response.data.steps;
service.status.index = 0;
_installerModel.installId = response.data.installId;
service.findNextStep();
if (!_status.all) {
//pre-load the error page, if an error occurs, the page might not be able to load
// so we want to make sure it's available in the templatecache first
$templateRequest("views/install/error.html").then(x => {
service.getSteps().then(response => {
service.status.steps = response.data.steps;
service.status.index = 0;
_installerModel.installId = response.data.installId;
service.findNextStep();
$timeout(function(){
service.status.loading = false;
service.status.configuring = true;
}, 2000);
});
}
$timeout(function() {
service.status.loading = false;
service.status.configuring = true;
},
2000);
});
});
}
},
//loads available packages from our.umbraco.com