From b37f1fc1f503750704e8203bc08ff8e50ff7ec5e Mon Sep 17 00:00:00 2001 From: Alex van den Hoogen Date: Wed, 25 Jan 2017 15:25:46 +0100 Subject: [PATCH] Fix for issue 1059. commandExecutionTimeoutSeconds was defined twice in the Chocolatey configuration. With this pull request, only the primary key is used. This fixes the incorrect behaviour that choco exhibited when changing this value through `choco config`. Closes #1059 #973 . --- .../ApplicationParameters.cs | 1 - .../builders/ConfigurationBuilder.cs | 20 ++++++------------- .../configuration/chocolatey.config | 1 - 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/chocolatey/infrastructure.app/ApplicationParameters.cs b/src/chocolatey/infrastructure.app/ApplicationParameters.cs index d74d77755d..63f2752523 100644 --- a/src/chocolatey/infrastructure.app/ApplicationParameters.cs +++ b/src/chocolatey/infrastructure.app/ApplicationParameters.cs @@ -132,7 +132,6 @@ public static class ConfigSettings { public static readonly string CacheLocation = "cacheLocation"; public static readonly string ContainsLegacyPackageInstalls = "containsLegacyPackageInstalls"; - public static readonly string CommandExecutionTimeoutSeconds = "commandExecutionTimeoutSeconds"; public static readonly string Proxy = "proxy"; public static readonly string ProxyUser = "proxyUser"; public static readonly string ProxyPassword = "proxyPassword"; diff --git a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs index 644929f9d9..bf057b3c9c 100644 --- a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs +++ b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs @@ -194,21 +194,13 @@ private static void set_config_items(ChocolateyConfiguration config, ConfigFileS config.CacheLocation = fileSystem.combine_paths(ApplicationParameters.InstallLocation, "temp"); } - var originalCommandTimeout = configFileSettings.CommandExecutionTimeoutSeconds; - var commandExecutionTimeoutSeconds = -1; - int.TryParse( - set_config_item( - ApplicationParameters.ConfigSettings.CommandExecutionTimeoutSeconds, - configFileSettings, - originalCommandTimeout == 0 ? - ApplicationParameters.DefaultWaitForExitInSeconds.to_string() - : originalCommandTimeout.to_string(), - "Default timeout for command execution."), - out commandExecutionTimeoutSeconds); - config.CommandExecutionTimeoutSeconds = commandExecutionTimeoutSeconds; - if (configFileSettings.CommandExecutionTimeoutSeconds <= 0) + if (configFileSettings.CommandExecutionTimeoutSeconds > 0) + { + config.CommandExecutionTimeoutSeconds = configFileSettings.CommandExecutionTimeoutSeconds; + } + else { - set_config_item(ApplicationParameters.ConfigSettings.CommandExecutionTimeoutSeconds, configFileSettings, ApplicationParameters.DefaultWaitForExitInSeconds.to_string(), "Default timeout for command execution.", forceSettingValue: true); + set_config_item(ApplicationParameters.DefaultWaitForExitInSeconds.to_string(), configFileSettings, ApplicationParameters.DefaultWaitForExitInSeconds.to_string(), "Default timeout for command execution.", forceSettingValue: true); config.CommandExecutionTimeoutSeconds = ApplicationParameters.DefaultWaitForExitInSeconds; } diff --git a/src/chocolatey/infrastructure.app/configuration/chocolatey.config b/src/chocolatey/infrastructure.app/configuration/chocolatey.config index 2a4275993d..e6c7900498 100644 --- a/src/chocolatey/infrastructure.app/configuration/chocolatey.config +++ b/src/chocolatey/infrastructure.app/configuration/chocolatey.config @@ -3,7 +3,6 @@ -