From f6530e4045b05dfe6a2b0baeafa9c730c83594e1 Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Thu, 25 Mar 2021 14:32:24 +0100 Subject: [PATCH] (#1866) Limit pending package removal to top level 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 --- .../infrastructure.app/tasks/RemovePendingPackagesTask.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chocolatey/infrastructure.app/tasks/RemovePendingPackagesTask.cs b/src/chocolatey/infrastructure.app/tasks/RemovePendingPackagesTask.cs index b2e85bc4ef..bc50d12a91 100644 --- a/src/chocolatey/infrastructure.app/tasks/RemovePendingPackagesTask.cs +++ b/src/chocolatey/infrastructure.app/tasks/RemovePendingPackagesTask.cs @@ -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));