Merge pull request #2695 from umbraco/temp8-mediapath

New mediapath scheme becomes default
This commit is contained in:
Claus
2018-06-19 08:57:16 +02:00
committed by GitHub
3 changed files with 19 additions and 14 deletions

View File

@@ -20,6 +20,9 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
[ConfigurationProperty("UploadAllowDirectories")]
internal InnerTextConfigurationElement<bool> UploadAllowDirectories => GetOptionalTextElement("UploadAllowDirectories", true);
[ConfigurationProperty("UseTheNewMediaPathScheme")]
internal InnerTextConfigurationElement<bool> UseTheNewMediaPathScheme => GetOptionalTextElement("UseTheNewMediaPathScheme", true);
public IEnumerable<IContentErrorPage> 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;

View File

@@ -23,7 +23,9 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
bool ResolveUrlsFromTextString { get; }
bool UploadAllowDirectories { get; }
bool UploadAllowDirectories { get; }
bool UseTheNewMediaPathScheme { get; }
IEnumerable<IContentErrorPage> Error404Collection { get; }

View File

@@ -28,13 +28,6 @@ namespace Umbraco.Core.IO
private long _folderCounter;
private bool _folderCounterInitialized;
// fixme - remove
//private static readonly Dictionary<int, string> DefaultSizes = new Dictionary<int, string>
//{
// { 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;
/// <summary>
/// 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 <paramref name="prevpath"/>. Else, we CREATE a new one. Each time we are invoked.</remarks>
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
}
/// <summary>