From 8308d66d66dea50a3edb499452ecd24bc089f32b Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Thu, 10 Sep 2015 23:37:10 +0100 Subject: [PATCH] Resetting shell state in case of an unexpected exception during setup. --- .../Orchard.Setup/Services/SetupService.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs index 94bf7d83a..0327e4022 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs @@ -69,6 +69,17 @@ namespace Orchard.Setup.Services { } public string Setup(SetupContext context) { + var initialState = _shellSettings.State; + try { + return SetupInternal(context); + } + catch { + _shellSettings.State = initialState; + throw; + } + } + + private string SetupInternal(SetupContext context) { string executionId; Logger.Information("Running setup for tenant '{0}'.", _shellSettings.Name); @@ -96,7 +107,7 @@ namespace Orchard.Setup.Services { shellSettings.DataConnectionString = context.DatabaseConnectionString; shellSettings.DataTablePrefix = context.DatabaseTablePrefix; } - + shellSettings.EncryptionAlgorithm = "AES"; // Randomly generated key. @@ -173,9 +184,8 @@ namespace Orchard.Setup.Services { throw; } } - - _shellSettingsManager.SaveSettings(shellSettings); + _shellSettingsManager.SaveSettings(shellSettings); return executionId; }