diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 2143f89c4..3f3500e17 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -858,6 +858,8 @@ public virtual ConcurrentDictionary uninstall_run(Chocola try { + var resetConfigAction = new Action(newConfig => config = newConfig.deep_copy()); + Action action = null; if (config.SourceType == SourceType.normal) { @@ -866,7 +868,7 @@ public virtual ConcurrentDictionary uninstall_run(Chocola var environmentBefore = get_environment_before(config); var beforeUninstallAction = new Action(packageResult => before_package_modify(packageResult, config)); - var results = perform_source_runner_function(config, r => r.uninstall_run(config, action, beforeUninstallAction)); + var results = perform_source_runner_function(config, r => r.uninstall_run(config, action, resetConfigAction, beforeUninstallAction)); foreach (var result in results) { diff --git a/src/chocolatey/infrastructure.app/services/CygwinService.cs b/src/chocolatey/infrastructure.app/services/CygwinService.cs index 4de3bb971..4a185f928 100644 --- a/src/chocolatey/infrastructure.app/services/CygwinService.cs +++ b/src/chocolatey/infrastructure.app/services/CygwinService.cs @@ -277,7 +277,7 @@ public void uninstall_noop(ChocolateyConfiguration config, Action this.Log().Warn(ChocolateyLoggers.Important, "{0} does not implement uninstall".format_with(APP_NAME)); } - public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action beforeUninstallAction = null) + public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action resetConfigAction, Action beforeUninstallAction = null) { throw new NotImplementedException("{0} does not implement upgrade".format_with(APP_NAME)); } diff --git a/src/chocolatey/infrastructure.app/services/ISourceRunner.cs b/src/chocolatey/infrastructure.app/services/ISourceRunner.cs index 316502902..a33b8409c 100644 --- a/src/chocolatey/infrastructure.app/services/ISourceRunner.cs +++ b/src/chocolatey/infrastructure.app/services/ISourceRunner.cs @@ -103,8 +103,9 @@ public interface ISourceRunner /// /// The configuration. /// The action to continue with when upgrade is successful. + /// The action that can be used to reset the configuration in the caller /// The action (if any) to run on any currently installed package before triggering the uninstall. /// results of installs - ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action beforeUninstallAction = null); + ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action resetConfigAction, Action beforeUninstallAction = null); } } \ No newline at end of file diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index c6d546c2f..cd0bcadd0 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -1235,7 +1235,8 @@ private void remove_nuget_cache_for_package(IPackage installedPackage) public void uninstall_noop(ChocolateyConfiguration config, Action continueAction) { - var results = uninstall_run(config, continueAction, performAction: false); + var resetConfigAction = new Action(newConfig => { }); + var results = uninstall_run(config, continueAction, false, resetConfigAction); foreach (var packageResult in results.or_empty_list_if_null()) { var package = packageResult.Value.Package; @@ -1243,12 +1244,12 @@ public void uninstall_noop(ChocolateyConfiguration config, Action } } - public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action beforeUninstallAction = null) + public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action resetConfigAction, Action beforeUninstallAction = null) { - return uninstall_run(config, continueAction, performAction: true, beforeUninstallAction: beforeUninstallAction); + return uninstall_run(config, continueAction, true, resetConfigAction, beforeUninstallAction); } - public virtual ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, bool performAction, Action beforeUninstallAction = null) + public virtual ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, bool performAction, Action resetConfigAction, Action beforeUninstallAction = null) { var packageUninstalls = new ConcurrentDictionary(StringComparer.InvariantCultureIgnoreCase); diff --git a/src/chocolatey/infrastructure.app/services/PythonService.cs b/src/chocolatey/infrastructure.app/services/PythonService.cs index 2c953117b..ecef571c3 100644 --- a/src/chocolatey/infrastructure.app/services/PythonService.cs +++ b/src/chocolatey/infrastructure.app/services/PythonService.cs @@ -484,7 +484,7 @@ public void uninstall_noop(ChocolateyConfiguration config, Action this.Log().Info("Would have run '{0} {1}'".format_with(_exePath.escape_curly_braces(), args.escape_curly_braces())); } - public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action beforeUninstallAction = null) + public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action resetConfigAction, Action beforeUninstallAction = null) { set_executable_path_if_not_set(); var args = build_args(config, _uninstallArguments); diff --git a/src/chocolatey/infrastructure.app/services/RubyGemsService.cs b/src/chocolatey/infrastructure.app/services/RubyGemsService.cs index 3f6d1ce7b..a7f55a78d 100644 --- a/src/chocolatey/infrastructure.app/services/RubyGemsService.cs +++ b/src/chocolatey/infrastructure.app/services/RubyGemsService.cs @@ -275,7 +275,7 @@ public void uninstall_noop(ChocolateyConfiguration config, Action this.Log().Warn(ChocolateyLoggers.Important, "{0} does not implement uninstall".format_with(APP_NAME)); } - public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action beforeUninstallAction = null) + public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action resetConfigAction, Action beforeUninstallAction = null) { throw new NotImplementedException("{0} does not implement uninstall".format_with(APP_NAME)); } diff --git a/src/chocolatey/infrastructure.app/services/WebPiService.cs b/src/chocolatey/infrastructure.app/services/WebPiService.cs index 70fd30568..410de9daf 100644 --- a/src/chocolatey/infrastructure.app/services/WebPiService.cs +++ b/src/chocolatey/infrastructure.app/services/WebPiService.cs @@ -268,7 +268,7 @@ public void uninstall_noop(ChocolateyConfiguration config, Action this.Log().Warn(ChocolateyLoggers.Important, "{0} does not implement uninstall".format_with(APP_NAME)); } - public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action beforeUninstallAction = null) + public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action resetConfigAction, Action beforeUninstallAction = null) { throw new NotImplementedException("{0} does not implement uninstall".format_with(APP_NAME)); } diff --git a/src/chocolatey/infrastructure.app/services/WindowsFeatureService.cs b/src/chocolatey/infrastructure.app/services/WindowsFeatureService.cs index 1011ff882..633c40e24 100644 --- a/src/chocolatey/infrastructure.app/services/WindowsFeatureService.cs +++ b/src/chocolatey/infrastructure.app/services/WindowsFeatureService.cs @@ -341,7 +341,7 @@ public void uninstall_noop(ChocolateyConfiguration config, Action this.Log().Info("Would have run '{0} {1}'".format_with(_exePath.escape_curly_braces(), args.escape_curly_braces())); } - public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action beforeUninstallAction = null) + public ConcurrentDictionary uninstall_run(ChocolateyConfiguration config, Action continueAction, Action resetConfigAction, Action beforeUninstallAction = null) { set_executable_path_if_not_set(); var args = build_args(config, _uninstallArguments);