Skip to content

Commit

Permalink
Merge branch 'pr1211' into stable
Browse files Browse the repository at this point in the history
* pr1211:
  (GH-1210) CacheLocation - Prevent nested chocolatey directories
  • Loading branch information
ferventcoder committed Mar 28, 2017
2 parents 8dc774e + 39b04f9 commit 3046d60
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -195,7 +195,16 @@ private static void set_machine_sources(ChocolateyConfiguration config, ConfigFi
private static void set_config_items(ChocolateyConfiguration config, ConfigFileSettings configFileSettings, IFileSystem fileSystem)
{
config.CacheLocation = Environment.ExpandEnvironmentVariables(set_config_item(ApplicationParameters.ConfigSettings.CacheLocation, configFileSettings, string.IsNullOrWhiteSpace(configFileSettings.CacheLocation) ? string.Empty : configFileSettings.CacheLocation, "Cache location if not TEMP folder."));
if (string.IsNullOrWhiteSpace(config.CacheLocation)) config.CacheLocation = fileSystem.combine_paths(fileSystem.get_temp_path(), "chocolatey"); // System.Environment.GetEnvironmentVariable("TEMP");
if (string.IsNullOrWhiteSpace(config.CacheLocation)) {
config.CacheLocation = fileSystem.get_temp_path(); // System.Environment.GetEnvironmentVariable("TEMP");
// TEMP gets set in EnvironmentSettings, so it may already have
// chocolatey in the path when it installs the next package from
// the API.
if(!config.CacheLocation.EndsWith("chocolatey")) {
config.CacheLocation = fileSystem.combine_paths(fileSystem.get_temp_path(), "chocolatey");
}
}

// if it is still empty, use temp in the Chocolatey install directory.
if (string.IsNullOrWhiteSpace(config.CacheLocation)) config.CacheLocation = fileSystem.combine_paths(ApplicationParameters.InstallLocation, "temp");

Expand Down

0 comments on commit 3046d60

Please sign in to comment.