Lookup plugin lang / icons folders in a case insensitive way (#11985)

* Use lowercase lang folder name for packages lang files

Use lowercase lang folder name for packages lang files to be consistent with Umbraco's casing

* Case insensitive `lang` folder lookup

* Comment grammar

* Setup lower case appl_plugin icons folder path

* Update Constants-SystemDirectories.cs

* Check both casings for the AppPluginIcons path

* Fixed spelling mistake + avoid multiple Exists checks

* Add IsCaseSensitiveFileSystem to IHostingEnvironment

* Add IsCaseSensitiveFileSystem to AspNetCoreHostingEnvironment

* Undo last changes

* Undo last changed

* Add FileSystemUtility

* Only perform second iconPath if OS is case sensitive

* Undo changes

* Undo changes

* Remove filesystem utils file

* Added HostingEnvironmentExtensions.cs

* Use IsCaseSensitiveFileSystem extension method

* Use the Umbraco.Extensions namespace

* Simplify IsCaseSensitiveFileSystem

* Better naming

* Use PluginIcons

* Remove unused using statement

* Delete HostingEnvironmentExtensions.cs

* Update IconService.cs

* Comment clarity

* Update src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Services.cs

Co-authored-by: Paul Johnson <pmj+github@ologn.co.uk>

Co-authored-by: Paul Johnson <pmj+github@ologn.co.uk>
Co-authored-by: Michael Latouche <michael@crossingpaths.be>
This commit is contained in:
Matt Brailsford
2022-02-16 23:04:41 +00:00
committed by GitHub
parent 79817f5463
commit 555b4fadf1
3 changed files with 21 additions and 4 deletions

View File

@@ -1,3 +1,5 @@
using System;
namespace Umbraco.Cms.Core
{
public static partial class Constants
@@ -42,7 +44,11 @@ namespace Umbraco.Cms.Core
public const string Install = "~/install";
public const string AppPlugins = "/App_Plugins";
public static string AppPluginIcons => "/Backoffice/Icons";
[Obsolete("Use PluginIcons instead")]
public const string AppPluginIcons = "/Backoffice/Icons";
public const string PluginIcons = "/backoffice/icons";
public const string CreatedPackages = "/created-packages";

View File

@@ -122,7 +122,8 @@ namespace Umbraco.Cms.Infrastructure.DependencyInjection
var pluginLangFolders = appPlugins.Exists == false
? Enumerable.Empty<LocalizedTextServiceSupplementaryFileSource>()
: appPlugins.GetDirectories()
.SelectMany(x => x.GetDirectories("Lang", SearchOption.AllDirectories))
// Check for both Lang & lang to support case sensitive file systems.
.SelectMany(x => x.GetDirectories("?ang", SearchOption.AllDirectories).Where(x => x.Name.InvariantEquals("lang")))
.SelectMany(x => x.GetFiles("*.xml", SearchOption.TopDirectoryOnly))
.Select(x => new LocalizedTextServiceSupplementaryFileSource(x, false));

View File

@@ -104,8 +104,18 @@ namespace Umbraco.Cms.Web.BackOffice.Services
// iterate sub directories of app plugins
foreach (var dir in appPlugins.EnumerateDirectories())
{
var iconPath = _hostingEnvironment.MapPathContentRoot($"{Constants.SystemDirectories.AppPlugins}/{dir.Name}{Constants.SystemDirectories.AppPluginIcons}");
if (Directory.Exists(iconPath))
// AppPluginIcons path was previoulsy the wrong case, so we first check for the prefered directory
// and then check the legacy directory.
var iconPath = _hostingEnvironment.MapPathContentRoot($"{Constants.SystemDirectories.AppPlugins}/{dir.Name}{Constants.SystemDirectories.PluginIcons}");
var iconPathExists = Directory.Exists(iconPath);
if (!iconPathExists)
{
iconPath = _hostingEnvironment.MapPathContentRoot($"{Constants.SystemDirectories.AppPlugins}/{dir.Name}{Constants.SystemDirectories.AppPluginIcons}");
iconPathExists = Directory.Exists(iconPath);
}
if (iconPathExists)
{
var dirIcons = new DirectoryInfo(iconPath).EnumerateFiles("*.svg", SearchOption.TopDirectoryOnly);
icons.UnionWith(dirIcons);