Skip to content

Commit

Permalink
(#1443) Reset config after handling package results
Browse files Browse the repository at this point in the history
This updates the action used when handling package results
during upgrade to reset the configuration class that is initially
set.

This is done as an alternative way other than updating the source
runners themself with a breaking change to the interfaces.

This fixes a bug when useRememberedArguments is enabled that causes
arguments to be reused in the chocolateyInstall.ps1 when multiple
packages are upgraded. It happens because OptionSet.parse() sets the
configuration via the actions specified in the UpgradeCommand optionSet
setup (and likewise in configuration builder as well). It only sets
options that are saved, so if a later package does not have an option,
it is not set, and the previous option is reused.

This fixes the bug because it resets the configuration at the
ChocolateyPackageService level, which is enaugh to reset the
configuration for action that runs the PowerShell as well.

Co-authored-by: TheCakeIsNaOH <[email protected]>
  • Loading branch information
AdmiringWorm and TheCakeIsNaOH committed Sep 16, 2022
1 parent b6dbc3e commit 1959747
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -834,10 +834,15 @@ public virtual ConcurrentDictionary<string, PackageResult> upgrade_run(Chocolate

try
{
var originalConfig = config.deep_copy();
Action<PackageResult> action = null;
if (config.SourceType.is_equal_to(SourceTypes.NORMAL))
{
action = (packageResult) => handle_package_result(packageResult, config, CommandNameType.upgrade);
action = (packageResult) =>
{
handle_package_result(packageResult, config, CommandNameType.upgrade);
config = originalConfig.deep_copy();
};
}

get_environment_before(config, allowLogging: true);
Expand Down

0 comments on commit 1959747

Please sign in to comment.