V10: merge v8 blobstorage file deletion fix (#13415)
* Implement fix from v8 https://github.com/umbraco/Umbraco-CMS/pull/11998 * Clean-up Co-authored-by: Elitsa Marinovska <elm@umbraco.dk>
This commit is contained in:
@@ -467,7 +467,7 @@ public class CodeFileController : BackOfficeNotificationsController
|
|||||||
{
|
{
|
||||||
case Constants.Trees.PartialViews:
|
case Constants.Trees.PartialViews:
|
||||||
if (IsDirectory(
|
if (IsDirectory(
|
||||||
_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.PartialViews, virtualPath))))
|
_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.PartialViews, virtualPath)), _fileSystems.PartialViewsFileSystem!))
|
||||||
{
|
{
|
||||||
_fileService.DeletePartialViewFolder(virtualPath);
|
_fileService.DeletePartialViewFolder(virtualPath);
|
||||||
return Ok();
|
return Ok();
|
||||||
@@ -482,7 +482,7 @@ public class CodeFileController : BackOfficeNotificationsController
|
|||||||
|
|
||||||
case Constants.Trees.PartialViewMacros:
|
case Constants.Trees.PartialViewMacros:
|
||||||
if (IsDirectory(
|
if (IsDirectory(
|
||||||
_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.MacroPartials, virtualPath))))
|
_hostingEnvironment.MapPathContentRoot(Path.Combine(Constants.SystemDirectories.MacroPartials, virtualPath)), _fileSystems.MacroPartialsFileSystem!))
|
||||||
{
|
{
|
||||||
_fileService.DeletePartialViewMacroFolder(virtualPath);
|
_fileService.DeletePartialViewMacroFolder(virtualPath);
|
||||||
return Ok();
|
return Ok();
|
||||||
@@ -497,7 +497,7 @@ public class CodeFileController : BackOfficeNotificationsController
|
|||||||
|
|
||||||
case Constants.Trees.Scripts:
|
case Constants.Trees.Scripts:
|
||||||
if (IsDirectory(
|
if (IsDirectory(
|
||||||
_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoScriptsPath, virtualPath))))
|
_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoScriptsPath, virtualPath)), _fileSystems.ScriptsFileSystem!))
|
||||||
{
|
{
|
||||||
_fileService.DeleteScriptFolder(virtualPath);
|
_fileService.DeleteScriptFolder(virtualPath);
|
||||||
return Ok();
|
return Ok();
|
||||||
@@ -512,7 +512,7 @@ public class CodeFileController : BackOfficeNotificationsController
|
|||||||
return new UmbracoProblemResult("No Script or folder found with the specified path", HttpStatusCode.NotFound);
|
return new UmbracoProblemResult("No Script or folder found with the specified path", HttpStatusCode.NotFound);
|
||||||
case Constants.Trees.Stylesheets:
|
case Constants.Trees.Stylesheets:
|
||||||
if (IsDirectory(
|
if (IsDirectory(
|
||||||
_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoCssPath, virtualPath))))
|
_hostingEnvironment.MapPathWebRoot(Path.Combine(_globalSettings.UmbracoCssPath, virtualPath)), _fileSystems.StylesheetsFileSystem!))
|
||||||
{
|
{
|
||||||
_fileService.DeleteStyleSheetFolder(virtualPath);
|
_fileService.DeleteStyleSheetFolder(virtualPath);
|
||||||
return Ok();
|
return Ok();
|
||||||
@@ -827,13 +827,21 @@ public class CodeFileController : BackOfficeNotificationsController
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsDirectory(string path)
|
private bool IsDirectory(string path, IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
var dirInfo = new DirectoryInfo(path);
|
// If it's a physical filesystem check with directory info
|
||||||
|
if (fileSystem.CanAddPhysical)
|
||||||
|
{
|
||||||
|
var dirInfo = new DirectoryInfo(path);
|
||||||
|
|
||||||
// If you turn off indexing in Windows this will have the attribute:
|
// If you turn off indexing in Windows this will have the attribute:
|
||||||
// `FileAttributes.Directory | FileAttributes.NotContentIndexed`
|
// `FileAttributes.Directory | FileAttributes.NotContentIndexed`
|
||||||
return (dirInfo.Attributes & FileAttributes.Directory) != 0;
|
return (dirInfo.Attributes & FileAttributes.Directory) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise check the filesystem abstraction to see if the folder exists
|
||||||
|
// Since this is used for delete, it presumably exists if we're trying to delete it
|
||||||
|
return fileSystem.DirectoryExists(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is an internal class for passing stylesheet data from the client to the controller while editing
|
// this is an internal class for passing stylesheet data from the client to the controller while editing
|
||||||
|
|||||||
Reference in New Issue
Block a user