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

(GH-1866) Restrict pending package removal to top level #1941

Conversation

aerotog
Copy link
Contributor

@aerotog aerotog commented Oct 20, 2019

Resolves #1866.

Seemed like a pretty straight forward change. I considered adding a test, but there was no existing tests to mimic for the ITask implementing classes. Hopefully this change is small enough to not require additional code coverage.

Copy link
Member

@ferventcoder ferventcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good.

@@ -60,13 +60,13 @@ private void handle_message(PreRunMessage message)
{
this.Log().Debug(ChocolateyLoggers.Verbose, "[Pending] Removing all pending packages that should not be considered installed...");

var pendingFiles = _fileSystem.get_files(ApplicationParameters.PackagesLocation, ApplicationParameters.PackagePendingFileName, SearchOption.AllDirectories).ToList();
var pendingFiles = _fileSystem.get_files(ApplicationParameters.PackagesLocation, ApplicationParameters.PackagePendingFileName).ToList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the default to search top level only? It would be better to make it explicit here - SearchOption.TopDirectoryOnly (or whatever the correct option is).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, SearchOption.TopDirectoryOnly is the default option. It might be better to make it explicit in case that ever changes, but Resharper does mark it as redundant code since it's the default already. Let me know if you want this changed or not.

Copy link
Member

@ferventcoder ferventcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aerotog Actually I spoke a little too quickly - the changes look great, however the git commit message is lacking context of why. Please see https://github.com/chocolatey/choco/blob/master/CONTRIBUTING.md#prepare-commits and if you can fix up your comments, great! If you need help with that, please let us know.

Previously, chocolatey would search all sub directories when trying to
remove pending packages as part of other commands. This was causing
several second execution times when sub directories were large and/or
symlinked on a network drive.

By restricting the cleanup to the top directory only, the command
execution times will be much more consistent.
@aerotog aerotog force-pushed the hotfix/remove-pending-top-level-only branch from bba124c to 4eb556b Compare October 31, 2019 00:13
@aerotog
Copy link
Contributor Author

aerotog commented Oct 31, 2019

git commit message is lacking context of why

Commit body has been updated with more context.

@ferventcoder
Copy link
Member

Be pulling this in soon.

Copy link
Member

@ferventcoder ferventcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@gep13
Copy link
Member

gep13 commented Apr 16, 2021

@aerotog thank you for raising this PR. I am going to move forward with merging in a related PR (#2218) and will close this one out.

I very much appreciate you taking the time to address this problem in Chocolatey though, and apologies for taking so long to get to this.

@gep13 gep13 closed this Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Only search top level package folders when running the remove pending packages task
4 participants