diff --git a/src/Umbraco.Core/Configuration/ContentXmlStorage.cs b/src/Umbraco.Core/Configuration/ContentXmlStorage.cs new file mode 100644 index 0000000000..7cbbc70675 --- /dev/null +++ b/src/Umbraco.Core/Configuration/ContentXmlStorage.cs @@ -0,0 +1,9 @@ +namespace Umbraco.Core.Configuration +{ + internal enum ContentXmlStorage + { + Default, + AspNetTemp, + EnvironmentTemp + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Core/Configuration/GlobalSettings.cs index 525bff2999..fc2534633f 100644 --- a/src/Umbraco.Core/Configuration/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/GlobalSettings.cs @@ -520,12 +520,25 @@ namespace Umbraco.Core.Configuration } internal static bool ContentCacheXmlStoredInCodeGen + { + get { return ContentCacheXmlStorageLocation == ContentXmlStorage.AspNetTemp; } + } + + internal static ContentXmlStorage ContentCacheXmlStorageLocation { get { - //defaults to false - return ConfigurationManager.AppSettings.ContainsKey("umbracoContentXMLUseLocalTemp") - && bool.Parse(ConfigurationManager.AppSettings["umbracoContentXMLUseLocalTemp"]); //default to false + if (ConfigurationManager.AppSettings.ContainsKey("umbracoContentXMLStorage")) + { + return Enum.Parse(ConfigurationManager.AppSettings["umbracoContentXMLStorage"]); + } + if (ConfigurationManager.AppSettings.ContainsKey("umbracoContentXMLUseLocalTemp")) + { + return bool.Parse(ConfigurationManager.AppSettings["umbracoContentXMLUseLocalTemp"]) + ? ContentXmlStorage.AspNetTemp + : ContentXmlStorage.Default; + } + return ContentXmlStorage.Default; } } diff --git a/src/Umbraco.Core/IO/SystemFiles.cs b/src/Umbraco.Core/IO/SystemFiles.cs index 48bdea2884..437ddd3ef7 100644 --- a/src/Umbraco.Core/IO/SystemFiles.cs +++ b/src/Umbraco.Core/IO/SystemFiles.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Configuration; using System.IO; using System.Linq; @@ -72,15 +73,28 @@ namespace Umbraco.Core.IO { get { - if (GlobalSettings.ContentCacheXmlStoredInCodeGen && SystemUtilities.GetCurrentTrustLevel() == AspNetHostingPermissionLevel.Unrestricted) - { - return Path.Combine(HttpRuntime.CodegenDir, @"UmbracoData\umbraco.config"); + switch (GlobalSettings.ContentCacheXmlStorageLocation) + { + case ContentXmlStorage.AspNetTemp: + return Path.Combine(HttpRuntime.CodegenDir, @"UmbracoData\umbraco.config"); + case ContentXmlStorage.EnvironmentTemp: + var appDomainHash = HttpRuntime.AppDomainAppId.ToSHA1(); + var cachePath = Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoXml", + //include the appdomain hash is just a safety check, for example if a website is moved from worker A to worker B and then back + // to worker A again, in theory the %temp% folder should already be empty but we really want to make sure that its not + // utilizing an old path + appDomainHash); + return Path.Combine(cachePath, "umbraco.config"); + case ContentXmlStorage.Default: + return IOHelper.ReturnPath("umbracoContentXML", "~/App_Data/umbraco.config"); + default: + throw new ArgumentOutOfRangeException(); } - return IOHelper.ReturnPath("umbracoContentXML", "~/App_Data/umbraco.config"); } } [Obsolete("Use GlobalSettings.ContentCacheXmlStoredInCodeGen instead")] + [EditorBrowsable(EditorBrowsableState.Never)] internal static bool ContentCacheXmlStoredInCodeGen { get { return GlobalSettings.ContentCacheXmlStoredInCodeGen; } diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 4aca6bdf02..e03dabfa5f 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -179,6 +179,7 @@ + diff --git a/src/umbraco.businesslogic/IO/SystemFiles.cs b/src/umbraco.businesslogic/IO/SystemFiles.cs index 991ec0b29f..3c5841a31b 100644 --- a/src/umbraco.businesslogic/IO/SystemFiles.cs +++ b/src/umbraco.businesslogic/IO/SystemFiles.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Configuration; using System.IO; using System.Linq; @@ -54,7 +55,9 @@ namespace umbraco.IO get { return Umbraco.Core.IO.SystemFiles.ContentCacheXml; } } - public static bool ContentCacheXmlIsEphemeral + [Obsolete("This is not used and will be removed in future versions")] + [EditorBrowsable(EditorBrowsableState.Never)] + public static bool ContentCacheXmlIsEphemeral { get { return Umbraco.Core.IO.SystemFiles.ContentCacheXmlStoredInCodeGen; } }