Skip to content
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

archive.extract "clean: True" cannot delete top level files #52127

Closed
angeloudy opened this issue Mar 11, 2019 · 6 comments
Closed

archive.extract "clean: True" cannot delete top level files #52127

angeloudy opened this issue Mar 11, 2019 · 6 comments
Labels
Feature new functionality including changes to functionality and code refactors, etc. fixed-pls-verify fix is linked, bug author to confirm fix
Milestone

Comments

@angeloudy
Copy link
Contributor

angeloudy commented Mar 11, 2019

Description of Issue/Question

When apply archive.extract state, if clean is set to True, only files paths that belong to the zip file will be deleted.

For example, A zip file contains the following

test1.txt
test2.txt
testdir
testdir/test.txt

When applying archive.extract, everything in the list above will be deleted before the archive is extracted. However, if I add another file to the target directory test3.txt, it will never be deleted.

It's the same when you update your archive, say test2.txt is no longer part of the archive, test2.txt will never get deleted in the target directory.

This has caused some drama for us because we use archive.extract to deploy a lot of applications.

@angeloudy
Copy link
Contributor Author

This could be resolved by always having a top level directory. But the problem with that is you may have to rename the director after extraction, which make the checksum useless.

@Ch3LL
Copy link
Contributor

Ch3LL commented Mar 11, 2019

glancing at the code it looks like this is done on purpose. we could possibly add a new argument that deletes the files in the directory it extracts the archive too

@Ch3LL Ch3LL added the Feature new functionality including changes to functionality and code refactors, etc. label Mar 11, 2019
@Ch3LL Ch3LL added this to the Approved milestone Mar 11, 2019
@angeloudy
Copy link
Contributor Author

angeloudy commented Mar 11, 2019

@Ch3LL
That would be great.
If toplevel_dir is set, then ignore enforce_toplevel.

If there's more than one directory or any file exists in the top level, create toplevel_dir and then append toplevel_dir to name;
If there only one dir in the top level, rename the toplevel dir to toplevel_dir after extraction;

@Oloremo
Copy link
Contributor

Oloremo commented Nov 26, 2019

I think that is what you want: #55418

@Ch3LL
Copy link
Contributor

Ch3LL commented Dec 17, 2019

ping @angeloudy can you verify the fix in #55418 looks like its ready to be closed.

@Ch3LL Ch3LL added the fixed-pls-verify fix is linked, bug author to confirm fix label Dec 17, 2019
@angeloudy
Copy link
Contributor Author

@Ch3LL verified. Thanks for adding the new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature new functionality including changes to functionality and code refactors, etc. fixed-pls-verify fix is linked, bug author to confirm fix
Projects
None yet
Development

No branches or pull requests

3 participants