Updated 2.0 portal upgrade code to make it idempotent

This commit is contained in:
feodor_fitsner 2012-09-25 16:54:03 -07:00
parent c0276a7369
commit a187888c05
4 changed files with 14 additions and 10 deletions

View file

@ -31,7 +31,7 @@ namespace WebsitePanel.Setup
{ {
return UpdateBase(obj, return UpdateBase(obj,
minimalInstallerVersion: "2.0.0", minimalInstallerVersion: "2.0.0",
versionToUpgrade: "1.2.1", versionToUpgrade: "1.2.1,2.0.0",
updateSql: true); updateSql: true);
} }
} }

View file

@ -31,7 +31,7 @@ namespace WebsitePanel.Setup
{ {
return UpdateBase(obj, return UpdateBase(obj,
minimalInstallerVersion: "2.0.0", minimalInstallerVersion: "2.0.0",
versionsToUpgrade: "1.2.1", versionsToUpgrade: "1.2.1,2.0.0",
updateSql: false, updateSql: false,
versionSpecificAction: new InstallAction(ActionTypes.ConfigureSecureSessionModuleInWebConfig)); versionSpecificAction: new InstallAction(ActionTypes.ConfigureSecureSessionModuleInWebConfig));
} }

View file

@ -30,7 +30,7 @@ namespace WebsitePanel.Setup
{ {
return Server.UpdateBase(obj, return Server.UpdateBase(obj,
minimalInstallerVersion: "2.0.0", minimalInstallerVersion: "2.0.0",
versionToUpgrade: "1.2.1", versionToUpgrade: "1.2.1,2.0.0",
updateSql: false); updateSql: false);
} }
} }

View file

@ -325,13 +325,17 @@ namespace WebsitePanel.Setup
if (webServer != null) if (webServer != null)
{ {
var modules = doc.CreateElement(iis6 ? "httpModules" : "modules"); string modulesNodeName = iis6 ? "httpModules" : "modules";
if (webServer.SelectSingleNode(modulesNodeName + "/add[@name='SecureSession']") == null)
{
var modules = doc.CreateElement(modulesNodeName);
webServer.AppendChild(modules); webServer.AppendChild(modules);
var sessionModule = doc.CreateElement("add"); var sessionModule = doc.CreateElement("add");
sessionModule.SetAttribute("name", "SecureSession"); sessionModule.SetAttribute("name", "SecureSession");
sessionModule.SetAttribute("type", "WebsitePanel.WebPortal.SecureSessionModule"); sessionModule.SetAttribute("type", "WebsitePanel.WebPortal.SecureSessionModule");
modules.AppendChild(sessionModule); modules.AppendChild(sessionModule);
} }
}
// update /system.web/httpRuntime element // update /system.web/httpRuntime element
var httpRuntime = doc.SelectSingleNode("configuration/system.web/httpRuntime") as XmlElement; var httpRuntime = doc.SelectSingleNode("configuration/system.web/httpRuntime") as XmlElement;
@ -343,7 +347,7 @@ namespace WebsitePanel.Setup
// <add key="SessionValidationKey" value="XXXXXX" /> // <add key="SessionValidationKey" value="XXXXXX" />
//</appSettings> //</appSettings>
var appSettings = doc.SelectSingleNode("configuration/appSettings"); var appSettings = doc.SelectSingleNode("configuration/appSettings");
if (appSettings != null) if (appSettings != null && appSettings.SelectSingleNode("add[@key='SessionValidationKey']") == null)
{ {
var sessionKey = doc.CreateElement("add"); var sessionKey = doc.CreateElement("add");
sessionKey.SetAttribute("key", "SessionValidationKey"); sessionKey.SetAttribute("key", "SessionValidationKey");