Skip to content

Commit

Permalink
(GH-562) Provide download cache information
Browse files Browse the repository at this point in the history
If download cache is available, provide it for use to download instead.
  • Loading branch information
ferventcoder committed Jan 21, 2016
1 parent 6cc681e commit 16bea9e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/chocolatey/infrastructure.app/services/PowershellService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ namespace chocolatey.infrastructure.app.services
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using adapters;
using builders;
using commandline;
using configuration;
using cryptography;
using domain;
using filesystem;
using infrastructure.commands;
Expand Down Expand Up @@ -207,6 +210,17 @@ public bool run_action(ChocolateyConfiguration configuration, PackageResult pack
// Environment.SetEnvironmentVariable("ChocolateyEnvironmentQuiet","true");
//}

if (package.IsDownloadCacheAvailable)
{
foreach (var downloadCache in package.DownloadCache.or_empty_list_if_null())
{
var urlKey = CryptoHashProvider.hash_value(downloadCache.OriginalUrl, CryptoHashProviderType.Sha256).Replace("=",string.Empty);
Environment.SetEnvironmentVariable("CacheFile_{0}".format_with(urlKey), downloadCache.FileName);
Environment.SetEnvironmentVariable("CacheChecksum_{0}".format_with(urlKey), downloadCache.Checksum);
//Environment.SetEnvironmentVariable("CacheChecksumType_{0}".format_with(urlKey), "md5");
}
}

this.Log().Debug(ChocolateyLoggers.Important, "Contents of '{0}':".format_with(chocoPowerShellScript));
string chocoPowerShellScriptContents = _fileSystem.read_file(chocoPowerShellScript);
this.Log().Debug(chocoPowerShellScriptContents.escape_curly_braces());
Expand Down

0 comments on commit 16bea9e

Please sign in to comment.