Skip to content

Commit

Permalink
(chocolatey#2111) Deep copy config
Browse files Browse the repository at this point in the history
Always deep copy the config when making a backup originalConfig. This
ensures that when the config is reset it gets fully reset. Fixes issues
with reuse of arguments when useRememberedArgumentsForUpgrades is
enabled.

Also should fix chocolatey#1443, not just chocolatey#2111
  • Loading branch information
TheCakeIsNaOH authored and gep13 committed Apr 21, 2021
1 parent 9ae705d commit 49df0c7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/chocolatey/infrastructure.app/services/NugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public virtual ConcurrentDictionary<string, PackageResult> install_run(Chocolate
uninstallSuccessAction: null,
addUninstallHandler: true);

var originalConfig = config;
var originalConfig = config.deep_copy();

foreach (string packageName in packageNames.or_empty_list_if_null())
{
Expand Down Expand Up @@ -614,7 +614,7 @@ public virtual ConcurrentDictionary<string, PackageResult> upgrade_run(Chocolate
set_package_names_if_all_is_specified(config, () => { config.IgnoreDependencies = true; });
config.IgnoreDependencies = configIgnoreDependencies;

var originalConfig = config;
var originalConfig = config.deep_copy();

foreach (string packageName in config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null())
{
Expand Down Expand Up @@ -890,7 +890,7 @@ public virtual ConcurrentDictionary<string, PackageResult> get_outdated(Chocolat
set_package_names_if_all_is_specified(config, () => { config.IgnoreDependencies = true; });
var packageNames = config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().ToList();

var originalConfig = config;
var originalConfig = config.deep_copy();

foreach (var packageName in packageNames)
{
Expand Down Expand Up @@ -1357,7 +1357,7 @@ public virtual ConcurrentDictionary<string, PackageResult> uninstall_run(Chocola
config.ForceDependencies = false;
});

var originalConfig = config;
var originalConfig = config.deep_copy();

foreach (string packageName in config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null())
{
Expand Down

0 comments on commit 49df0c7

Please sign in to comment.