Skip to content

Commit

Permalink
(GH-1059) Fix: Unable to change command execution timeout
Browse files Browse the repository at this point in the history
When determining whether to use the default timeout, use the locally
set variable instead of using a deprecated config settings value.
Previously, when the deprecated value was set to "0" (the default), it
would not allow setting an execution timeout to anything other than the
default timeout of 2700. This has caused issues in newer installations
of Chocolatey (not upgraded) as the value of 0 would not allow changing
the execution timeout. It was looking at the deprecated timeout instead
of what was currently set or what was in the actual configuration value.

Fix this to look at the locally set variable that has already
determined what the setting is and whether it evaluates to 0 (not able
to parse or empty).

However, also allow for an actual setting of "0", which means never
time out (GH-1202) by looking at the string value prior to parsing to
see if it was set to zero.
  • Loading branch information
ferventcoder committed Mar 15, 2017
1 parent 43074fe commit b0a58f0
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private static void set_config_items(ChocolateyConfiguration config, ConfigFileS
var commandExecutionTimeout = set_config_item(ApplicationParameters.ConfigSettings.CommandExecutionTimeoutSeconds, configFileSettings, string.IsNullOrWhiteSpace(configFileSettings.CommandExecutionTimeoutSeconds.to_string()) ? ApplicationParameters.DefaultWaitForExitInSeconds.to_string() : configFileSettings.CommandExecutionTimeoutSeconds.to_string(), "Default timeout for command execution. '0' for infinite (starting in 0.10.4).");
int.TryParse(commandExecutionTimeout, out commandExecutionTimeoutSeconds);
config.CommandExecutionTimeoutSeconds = commandExecutionTimeoutSeconds;
if (configFileSettings.CommandExecutionTimeoutSeconds <= 0)
if (commandExecutionTimeout != "0" && commandExecutionTimeoutSeconds <= 0)
{
set_config_item(ApplicationParameters.ConfigSettings.CommandExecutionTimeoutSeconds, configFileSettings, ApplicationParameters.DefaultWaitForExitInSeconds.to_string(), "Default timeout for command execution. '0' for infinite (starting in 0.10.4).", forceSettingValue: true);
config.CommandExecutionTimeoutSeconds = ApplicationParameters.DefaultWaitForExitInSeconds;
Expand Down

0 comments on commit b0a58f0

Please sign in to comment.