-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[WIP] Added clean_top argument for the archive state #54013
Conversation
Folks, could you please look at the mentioned issue and in my implementation of this feature and tell if it's ok(both issue and implementation). If it's ok for you I'll write tests(not yet sure how) |
831d955
to
b63d87b
Compare
@@ -526,6 +527,9 @@ def extracted(name, | |||
|
|||
.. versionadded:: 2016.11.1 | |||
|
|||
clean_top : False | |||
Set this to ``True`` to remove a top level directory before the extration. |
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.
extraction
errors = [] | ||
log.debug('Removing directory %s due to clean_top set to True', name) | ||
try: | ||
salt.utils.files.rm_rf(name.rstrip(os.sep)) |
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.
Maybe rename the directory, if the archive.extract is successful, then delete, otherwise roll it back
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'm not sure here.
First of all, it adds complexity + a hidden requirement for a 2x space(to keep both old and new dir at some point of time).
Second is that the current clean: True
logic doesn't do it and I feel like it's more or less the same case.
Closed in favor of #55418 |
What does this PR do?
Adding new argument
clean_top
to the archive state. This allows the state to remove top level directory before the extraction.What issues does this PR fix or reference?
#54012
Previous Behavior
archive state was unable to do so by itself.
New Behavior
archive state now able to remove top level directory if requested
Tests written?
No(yet) - RFC required first
Commits signed with GPG?
Yes