Skip to content

Commit

Permalink
(chocolateyGH-1866) Restrict 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.
  • Loading branch information
aerotog committed Oct 31, 2019
1 parent 3b10e75 commit 4eb556b
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 4eb556b

Please sign in to comment.