Skip to content

Commit

Permalink
(#1866) Limit pending package removal to top level
Browse files Browse the repository at this point in the history
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.

Co-authored-by: Tim Guenthner <[email protected]>
  • Loading branch information
2 people authored and gep13 committed Apr 16, 2021
1 parent 759a416 commit f6530e4
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
foreach (var pendingFile in pendingFiles.or_empty_list_if_null())
{
var packageFolder = _fileSystem.get_directory_name(pendingFile);
string packageFolderName = _fileSystem.get_directory_info_for(packageFolder).Name;

var pendingSkipFiles = _fileSystem.get_files(packageFolder, PENDING_SKIP_FILE, SearchOption.AllDirectories).ToList();
var pendingSkipFiles = _fileSystem.get_files(packageFolder, PENDING_SKIP_FILE).ToList();
if (pendingSkipFiles.Count != 0)
{
this.Log().Warn("Pending file found for {0}, but a {1} file was also found. Skipping removal".format_with(packageFolderName, PENDING_SKIP_FILE));
Expand Down

0 comments on commit f6530e4

Please sign in to comment.