-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add folder cleanup support to CleanupInstaller #5090
Conversation
DNN Platform/DotNetNuke.Abstractions/Utilities/IFileSystemUtils.cs
Outdated
Show resolved
Hide resolved
|
||
var appPath = this.applicationStatusInfo.ApplicationMapPath; | ||
var fullPath = Path.Combine(appPath, normalized); | ||
if (!normalized.StartsWith(appPath, StringComparison.InvariantCultureIgnoreCase) || fullPath == appPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling we need to be more protective with this validation test as it would be very easy to corrupt an installation with this.
Values such as
- /DesktopModules
- /Portals/0
- /Bin
Or otherwise, and since this is a recursive delete, that doesn't expect folders to be empty I think we need to prevent at least our critical directories from being cleaned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point, although critical files could still get deleted using the glob
parameter.
Anyway, I have changed the original indiscriminate delete now with a new method that only deletes empty directories. This avoids the risk of any files being deleted by CleanupInstaller.
DNN Platform/Tests/DotNetNuke.Tests.Core/Services/Installer/CleanupInstallerTests.cs
Outdated
Show resolved
Hide resolved
16cfd32
to
274d7bc
Compare
This reverts commit 7becbf7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, thanks!
Summary
The
CleanupInstaller
class supports aglob
parameter that works well, but leaves an empty folder structure behind after deleting all files.This pull request adds support for a new
<folder>
element in the package schema that allows for recursive folder deletion.Usage:
The value of
path
is validated so that it can only reference valid paths inside the virtual directory.