From d2aecd12eb13e8ef56b031615fa8f7a277631c34 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 4 Mar 2014 19:20:36 +1100 Subject: [PATCH] Updates more installer logic, getting into the nitty gritty details with upgrades, etc... --- src/Umbraco.Core/ApplicationContext.cs | 3 + src/Umbraco.Core/DatabaseContext.cs | 29 +++++++ .../Install/InstallHelperTests.cs | 6 +- .../src/installer/steps/upgrade.html | 3 + .../steps/version7upgradereport.html | 3 + .../config/ClientDependency.config | 2 +- .../Controllers/InstallApiController.cs | 19 +++-- src/Umbraco.Web/Install/InstallHelper.cs | 84 ++++++++++--------- .../Install/InstallStatusTracker.cs | 43 +++++++++- .../InstallSteps/DatabaseConfigureStep.cs | 51 ++++------- .../InstallSteps/DatabaseInstallStep.cs | 13 ++- .../InstallSteps/DatabaseUpgradeStep.cs | 48 +++++++++-- .../InstallSteps/FilePermissionsStep.cs | 3 +- .../MajorVersion7UpgradeReport.cs | 16 ++-- .../InstallSteps/SetUmbracoVersionStep.cs | 3 +- .../InstallSteps/StarterKitCleanupStep.cs | 35 +++++--- .../InstallSteps/StarterKitDownloadStep.cs | 24 ++++-- .../InstallSteps/StarterKitInstallStep.cs | 34 ++++---- .../Install/InstallSteps/Upgrade.cs | 22 +++++ .../Install/InstallSteps/UserStep.cs | 34 ++++++-- .../Install/Models/InstallSetup.cs | 9 +- .../Install/Models/InstallSetupStep.cs | 6 +- .../Models/InstallSetupStepAttribute.cs | 10 ++- .../Install/Models/InstallStatusType.cs | 27 ------ .../Install/Models/InstallationType.cs | 11 +++ src/Umbraco.Web/Umbraco.Web.csproj | 3 +- 26 files changed, 355 insertions(+), 186 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/installer/steps/upgrade.html create mode 100644 src/Umbraco.Web.UI.Client/src/installer/steps/version7upgradereport.html create mode 100644 src/Umbraco.Web/Install/InstallSteps/Upgrade.cs delete mode 100644 src/Umbraco.Web/Install/Models/InstallStatusType.cs create mode 100644 src/Umbraco.Web/Install/Models/InstallationType.cs diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs index 79e4a72756..f1bb929a94 100644 --- a/src/Umbraco.Core/ApplicationContext.cs +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -165,6 +165,9 @@ namespace Umbraco.Core /// internal string OriginalRequestUrl { get; set; } + /// + /// Checks if the version configured matches the assembly version + /// private bool Configured { get diff --git a/src/Umbraco.Core/DatabaseContext.cs b/src/Umbraco.Core/DatabaseContext.cs index 5e0c1cd29f..435470a493 100644 --- a/src/Umbraco.Core/DatabaseContext.cs +++ b/src/Umbraco.Core/DatabaseContext.cs @@ -615,5 +615,34 @@ namespace Umbraco.Core public bool Success { get; set; } public string Percentage { get; set; } } + + internal bool IsConnectionStringConfigured(ConnectionStringSettings databaseSettings) + { + var dbIsSqlCe = false; + if (databaseSettings != null && databaseSettings.ProviderName != null) + dbIsSqlCe = databaseSettings.ProviderName == "System.Data.SqlServerCe.4.0"; + var sqlCeDatabaseExists = false; + if (dbIsSqlCe) + { + var parts = databaseSettings.ConnectionString.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + var dataSourcePart = parts.FirstOrDefault(x => x.InvariantStartsWith("Data Source=")); + if (dataSourcePart != null) + { + var datasource = dataSourcePart.Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory").ToString()); + var filePath = datasource.Replace("Data Source=", string.Empty); + sqlCeDatabaseExists = File.Exists(filePath); + } + } + + // Either the connection details are not fully specified or it's a SQL CE database that doesn't exist yet + if (databaseSettings == null + || string.IsNullOrWhiteSpace(databaseSettings.ConnectionString) || string.IsNullOrWhiteSpace(databaseSettings.ProviderName) + || (dbIsSqlCe && sqlCeDatabaseExists == false)) + { + return false; + } + + return true; + } } } \ No newline at end of file diff --git a/src/Umbraco.Tests/Install/InstallHelperTests.cs b/src/Umbraco.Tests/Install/InstallHelperTests.cs index ecce6d6b85..4c68a3df4a 100644 --- a/src/Umbraco.Tests/Install/InstallHelperTests.cs +++ b/src/Umbraco.Tests/Install/InstallHelperTests.cs @@ -10,6 +10,7 @@ using Newtonsoft.Json.Linq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Logging; +using Umbraco.Core.Persistence; using Umbraco.Web; using Umbraco.Web.Install; using Umbraco.Web.Install.Controllers; @@ -78,6 +79,7 @@ namespace Umbraco.Tests.Install { var appCtx = new ApplicationContext(CacheHelper.CreateDisabledCacheHelper()); ApplicationContext.EnsureContext(appCtx, true); + appCtx.DatabaseContext = new DatabaseContext(Mock.Of()); var umbCtx = UmbracoContext.EnsureContext( new Mock().Object, @@ -88,8 +90,8 @@ namespace Umbraco.Tests.Install var steps = helper.GetSteps().ToArray(); - //for upgrades 5, don't require execution (the db context is not configured so the upgrade report will not execute either) - Assert.AreEqual(5, steps.Count(x => x.RequiresExecution() == false)); + //for upgrades 4, don't require execution + Assert.AreEqual(4, steps.Count(x => x.RequiresExecution() == false)); } diff --git a/src/Umbraco.Web.UI.Client/src/installer/steps/upgrade.html b/src/Umbraco.Web.UI.Client/src/installer/steps/upgrade.html new file mode 100644 index 0000000000..8cbff93233 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/installer/steps/upgrade.html @@ -0,0 +1,3 @@ +
+ Start upgrade! +
\ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/installer/steps/version7upgradereport.html b/src/Umbraco.Web.UI.Client/src/installer/steps/version7upgradereport.html new file mode 100644 index 0000000000..651f7fd30b --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/installer/steps/version7upgradereport.html @@ -0,0 +1,3 @@ +
+ Upgrade report :) +
\ No newline at end of file diff --git a/src/Umbraco.Web.UI/config/ClientDependency.config b/src/Umbraco.Web.UI/config/ClientDependency.config index 1e4c529156..02486b0ff6 100644 --- a/src/Umbraco.Web.UI/config/ClientDependency.config +++ b/src/Umbraco.Web.UI/config/ClientDependency.config @@ -10,7 +10,7 @@ NOTES: * Compression/Combination/Minification is not enabled unless debug="false" is specified on the 'compiliation' element in the web.config * A new version will invalidate both client and server cache and create new persisted files --> - +