From 0d8f34c36418a9345a28468241689262da24e0ed Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Mon, 3 Apr 2017 09:01:57 -0700 Subject: [PATCH] (GH-1231) Use DirectoryInfo to evaluate CacheLocation The former fix (GH-1210) fails when the CacheLocation ends with a slash. This uses a DirectoryInfo instance to examine the last directory in the path in a more robust manner --- .../infrastructure.app/builders/ConfigurationBuilder.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs index 774bb61094..78ad073935 100644 --- a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs +++ b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs @@ -19,6 +19,7 @@ namespace chocolatey.infrastructure.app.builders using System; using System.Collections.Generic; using System.ComponentModel; + using System.IO; using System.Linq; using System.Reflection; using System.Text; @@ -199,8 +200,8 @@ private static void set_config_items(ChocolateyConfiguration config, ConfigFileS 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")) { + // the API. + if(!fileSystem.get_directory_info_for(config.CacheLocation).Name.Equals("chocolatey", StringComparison.OrdinalIgnoreCase)) { config.CacheLocation = fileSystem.combine_paths(fileSystem.get_temp_path(), "chocolatey"); } }