diff --git a/src/Umbraco.Core/DictionaryExtensions.cs b/src/Umbraco.Core/DictionaryExtensions.cs index fd6476fe21..ddfe963f48 100644 --- a/src/Umbraco.Core/DictionaryExtensions.cs +++ b/src/Umbraco.Core/DictionaryExtensions.cs @@ -15,6 +15,25 @@ namespace Umbraco.Core /// internal static class DictionaryExtensions { + + /// + /// Method to Get a value by the key. If the key doesn't exist it will create a new TVal object for the key and return it. + /// + /// + /// + /// + /// + /// + public static TVal GetOrCreate(this IDictionary dict, TKey key) + where TVal : class, new() + { + if (dict.ContainsKey(key) == false) + { + dict.Add(key, new TVal()); + } + return dict[key]; + } + /// /// Updates an item with the specified key with the specified value /// diff --git a/src/Umbraco.Web.UI.Client/src/installer/steps/permissionsreport.html b/src/Umbraco.Web.UI.Client/src/installer/steps/permissionsreport.html new file mode 100644 index 0000000000..c9fe9885ea --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/installer/steps/permissionsreport.html @@ -0,0 +1,26 @@ +
+

Your permission settings are not ready for umbraco

+

+ In order to run umbraco, you'll need to update your permission settings. + Detailed information about the correct file & folder permissions for Umbraco can be found + here. +

+

+ The following report list the permissions that are currently failing. Once the permissions are fixed press the 'Go back' button to restart the installation. +

+ +
    +
  • +

    {{category}}

    +
      +
    • + {{item}} +
    • +
    +
  • +
+ +

+ +

+
diff --git a/src/Umbraco.Web.UI.Client/src/less/installer.less b/src/Umbraco.Web.UI.Client/src/less/installer.less index e589315d49..604a97fd68 100644 --- a/src/Umbraco.Web.UI.Client/src/less/installer.less +++ b/src/Umbraco.Web.UI.Client/src/less/installer.less @@ -57,6 +57,7 @@ body { height: 550px; text-align: left; padding: 30px; + overflow:hidden; } @@ -222,3 +223,19 @@ height: 5px; right: 0; overflow: hidden; } + +.permissions-report { + overflow:auto; + height:320px; + margin:0; + display:block; + padding:0; +} + +.permissions-report > li { + list-style:none; +} + +.permissions-report h4 { + margin:7px; +} \ No newline at end of file diff --git a/src/Umbraco.Web/Install/InstallSteps/FilePermissionsStep.cs b/src/Umbraco.Web/Install/InstallSteps/FilePermissionsStep.cs index 2d43565fba..0c6e4b5ada 100644 --- a/src/Umbraco.Web/Install/InstallSteps/FilePermissionsStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/FilePermissionsStep.cs @@ -17,7 +17,7 @@ namespace Umbraco.Web.Install.InstallSteps { //first validate file permissions var permissionsOk = true; - var report = new List(); + var reportParts = new Dictionary>(); // Test default dir permissions foreach (var dir in FilePermissionHelper.PermissionDirs) @@ -25,8 +25,9 @@ namespace Umbraco.Web.Install.InstallSteps var result = SaveAndDeleteFile(IOHelper.MapPath(dir + "/configWizardPermissionTest.txt")); if (!result) { + var report = reportParts.GetOrCreate("Folder creation failed"); permissionsOk = false; - report.Add("Directory: ./" + dir); + report.Add(dir); } } @@ -36,8 +37,9 @@ namespace Umbraco.Web.Install.InstallSteps var result = OpenFileForWrite(IOHelper.MapPath(file)); if (!result) { + var report = reportParts.GetOrCreate("File writing failed"); permissionsOk = false; - report.Add("File: " + file); + report.Add(file); } } @@ -49,8 +51,9 @@ namespace Umbraco.Web.Install.InstallSteps SaveAndDeleteFile(IOHelper.MapPath(dir + "/configWizardPermissionTest.txt")); if (!result) { + var report = reportParts.GetOrCreate("File writing for packages failed"); permissionsOk = false; - report.Add("Directory: " + dir); + report.Add(dir); } } @@ -67,7 +70,8 @@ namespace Umbraco.Web.Install.InstallSteps if (tempFile.Substring(0, 1) == "/") tempFile = tempFile.Substring(1, tempFile.Length - 1); - report.Add(string.Format("File ./{0}. Error: {1}", tempFile, ee)); + var report = reportParts.GetOrCreate("Cache file writing failed"); + report.Add(tempFile); } // Test creation of folders @@ -80,12 +84,14 @@ namespace Umbraco.Web.Install.InstallSteps catch { permissionsOk = false; - report.Add("Folder creation failed"); + var report = reportParts.GetOrCreate("Media folder creation failed"); + report.Add("Could not create sub folders in " + SystemDirectories.Media); } + if (permissionsOk == false) { - throw new InstallException("Permission check failed", "permissionsReport", new { errors = report }); + throw new InstallException("Permission check failed", "permissionsreport", new { errors = reportParts }); } return null;