From d7d99e5c0058f82370393973dd959d669e8e8ec6 Mon Sep 17 00:00:00 2001 From: berg Date: Sat, 27 Feb 2021 19:26:36 +0100 Subject: [PATCH] Fixed issue found by cypress test. script/css folders was not deleted because it search in contentroot and not wwwroot --- .../Controllers/CodeFileController.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs b/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs index 25f8f21c01..ffdc45d5ac 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs @@ -338,7 +338,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers switch (type) { case Constants.Trees.PartialViews: - if (IsDirectory(virtualPath, Constants.SystemDirectories.PartialViews)) + if (IsDirectory(_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.PartialViews, virtualPath)))) { _fileService.DeletePartialViewFolder(virtualPath); return Ok(); @@ -350,7 +350,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers return new UmbracoProblemResult("No Partial View or folder found with the specified path", HttpStatusCode.NotFound); case Constants.Trees.PartialViewMacros: - if (IsDirectory(virtualPath, Constants.SystemDirectories.MacroPartials)) + if (IsDirectory(_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.MacroPartials, virtualPath)))) { _fileService.DeletePartialViewMacroFolder(virtualPath); return Ok(); @@ -362,7 +362,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers return new UmbracoProblemResult("No Partial View Macro or folder found with the specified path", HttpStatusCode.NotFound); case Constants.Trees.Scripts: - if (IsDirectory(virtualPath, _globalSettings.UmbracoScriptsPath)) + if (IsDirectory(_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoScriptsPath, virtualPath)))) { _fileService.DeleteScriptFolder(virtualPath); return Ok(); @@ -374,7 +374,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers } return new UmbracoProblemResult("No Script or folder found with the specified path", HttpStatusCode.NotFound); case Constants.Trees.Stylesheets: - if (IsDirectory(virtualPath, _globalSettings.UmbracoCssPath)) + if (IsDirectory(_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoCssPath, virtualPath)))) { _fileService.DeleteStyleSheetFolder(virtualPath); return Ok(); @@ -665,9 +665,8 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers return value; } - private bool IsDirectory(string virtualPath, string systemDirectory) + private bool IsDirectory(string path) { - var path = _hostingEnvironment.MapPathContentRoot(systemDirectory + "/" + virtualPath); var dirInfo = new DirectoryInfo(path); return dirInfo.Attributes == FileAttributes.Directory; }