diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs index 4a00aeb3ee..612437a688 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs @@ -20,6 +20,9 @@ namespace Umbraco.Core.Configuration.UmbracoSettings [ConfigurationProperty("UploadAllowDirectories")] internal InnerTextConfigurationElement UploadAllowDirectories => GetOptionalTextElement("UploadAllowDirectories", true); + [ConfigurationProperty("UseTheNewMediaPathScheme")] + internal InnerTextConfigurationElement UseTheNewMediaPathScheme => GetOptionalTextElement("UseTheNewMediaPathScheme", true); + public IEnumerable Error404Collection => Errors.Error404Collection; [ConfigurationProperty("errors", IsRequired = true)] @@ -105,6 +108,8 @@ namespace Umbraco.Core.Configuration.UmbracoSettings bool IContentSection.UploadAllowDirectories => UploadAllowDirectories; + bool IContentSection.UseTheNewMediaPathScheme => UseTheNewMediaPathScheme; + bool IContentSection.EnsureUniqueNaming => EnsureUniqueNaming; bool IContentSection.XmlCacheEnabled => XmlCacheEnabled; diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs index 879afd65bf..df0a39ad39 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs @@ -23,7 +23,9 @@ namespace Umbraco.Core.Configuration.UmbracoSettings bool ResolveUrlsFromTextString { get; } - bool UploadAllowDirectories { get; } + bool UploadAllowDirectories { get; } + + bool UseTheNewMediaPathScheme { get; } IEnumerable Error404Collection { get; } diff --git a/src/Umbraco.Core/IO/MediaFileSystem.cs b/src/Umbraco.Core/IO/MediaFileSystem.cs index 2c9773a9cb..b1404121e5 100644 --- a/src/Umbraco.Core/IO/MediaFileSystem.cs +++ b/src/Umbraco.Core/IO/MediaFileSystem.cs @@ -28,13 +28,6 @@ namespace Umbraco.Core.IO private long _folderCounter; private bool _folderCounterInitialized; - // fixme - remove - //private static readonly Dictionary DefaultSizes = new Dictionary - //{ - // { 100, "thumb" }, - // { 500, "big-thumb" } - //}; - public MediaFileSystem(IFileSystem wrapped) : base(wrapped) { @@ -52,10 +45,14 @@ namespace Umbraco.Core.IO internal ILogger Logger { get; set; } internal UploadAutoFillProperties UploadAutoFillProperties { get; } - - // note - this is currently experimental / being developed - //public static bool UseTheNewMediaPathScheme { get; set; } - public const bool UseTheNewMediaPathScheme = false; + + // fixme - work-in-progress + // the new scheme is now the default scheme - media items with old paths will still + // work, but whenever a file is uploaded, the new scheme is used. we have a temp. + // option to let people opt-out of the new scheme. eventually, the media filesystem + // will only support the new scheme - but it should be an interface, and it should + // be possible to switch its implementation to whatever people want to use + public bool UseTheNewMediaPathScheme => ContentConfig.UseTheNewMediaPathScheme; /// /// Deletes all files passed in. @@ -116,7 +113,6 @@ namespace Umbraco.Core.IO DeleteFile(file); #pragma warning disable 162 // unreachable code - // Not implemented yet, so need to disable warnings // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (UseTheNewMediaPathScheme == false) { @@ -160,7 +156,6 @@ namespace Umbraco.Core.IO string folder; #pragma warning disable 162 // unreachable code - // Not implemented yet, so need to disable warnings // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (UseTheNewMediaPathScheme == false) { @@ -207,6 +202,8 @@ namespace Umbraco.Core.IO /// specified by . Else, we CREATE a new one. Each time we are invoked. public string GetMediaPath(string filename, string prevpath, Guid cuid, Guid puid) { +#pragma warning disable 162 // unreachable code + // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (UseTheNewMediaPathScheme || string.IsNullOrWhiteSpace(prevpath)) return GetMediaPath(filename, cuid, puid); @@ -230,6 +227,7 @@ namespace Umbraco.Core.IO : folder + "-" + filename; return filepath; +#pragma warning restore 162 // unreachable code } ///