Skip to content

Commit 555b4fa

Browse files
mattbrailsfordp-m-jmikecp
authored
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 <[email protected]> Co-authored-by: Paul Johnson <[email protected]> Co-authored-by: Michael Latouche <[email protected]>
1 parent 79817f5 commit 555b4fa

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/Umbraco.Core/Constants-SystemDirectories.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System;
2+
13
namespace Umbraco.Cms.Core
24
{
35
public static partial class Constants
@@ -42,7 +44,11 @@ public static class SystemDirectories
4244
public const string Install = "~/install";
4345

4446
public const string AppPlugins = "/App_Plugins";
45-
public static string AppPluginIcons => "/Backoffice/Icons";
47+
48+
[Obsolete("Use PluginIcons instead")]
49+
public const string AppPluginIcons = "/Backoffice/Icons";
50+
public const string PluginIcons = "/backoffice/icons";
51+
4652
public const string CreatedPackages = "/created-packages";
4753

4854

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ private static LocalizedTextServiceFileSources SourcesFactory(IServiceProvider c
122122
var pluginLangFolders = appPlugins.Exists == false
123123
? Enumerable.Empty<LocalizedTextServiceSupplementaryFileSource>()
124124
: appPlugins.GetDirectories()
125-
.SelectMany(x => x.GetDirectories("Lang", SearchOption.AllDirectories))
125+
// Check for both Lang & lang to support case sensitive file systems.
126+
.SelectMany(x => x.GetDirectories("?ang", SearchOption.AllDirectories).Where(x => x.Name.InvariantEquals("lang")))
126127
.SelectMany(x => x.GetFiles("*.xml", SearchOption.TopDirectoryOnly))
127128
.Select(x => new LocalizedTextServiceSupplementaryFileSource(x, false));
128129

src/Umbraco.Web.BackOffice/Services/IconService.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,18 @@ private IEnumerable<FileInfo> GetAllIconsFiles()
104104
// iterate sub directories of app plugins
105105
foreach (var dir in appPlugins.EnumerateDirectories())
106106
{
107-
var iconPath = _hostingEnvironment.MapPathContentRoot($"{Constants.SystemDirectories.AppPlugins}/{dir.Name}{Constants.SystemDirectories.AppPluginIcons}");
108-
if (Directory.Exists(iconPath))
107+
// AppPluginIcons path was previoulsy the wrong case, so we first check for the prefered directory
108+
// and then check the legacy directory.
109+
var iconPath = _hostingEnvironment.MapPathContentRoot($"{Constants.SystemDirectories.AppPlugins}/{dir.Name}{Constants.SystemDirectories.PluginIcons}");
110+
var iconPathExists = Directory.Exists(iconPath);
111+
112+
if (!iconPathExists)
113+
{
114+
iconPath = _hostingEnvironment.MapPathContentRoot($"{Constants.SystemDirectories.AppPlugins}/{dir.Name}{Constants.SystemDirectories.AppPluginIcons}");
115+
iconPathExists = Directory.Exists(iconPath);
116+
}
117+
118+
if (iconPathExists)
109119
{
110120
var dirIcons = new DirectoryInfo(iconPath).EnumerateFiles("*.svg", SearchOption.TopDirectoryOnly);
111121
icons.UnionWith(dirIcons);

0 commit comments

Comments
 (0)