From e15c3ebccdf23f3bf509ad9d767eb7898d0be4a9 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Tue, 22 Sep 2015 23:54:11 -0500 Subject: [PATCH] (GH-405) Cache downloads by name and version When downloading files from the internet, cache the file in a folder with the package name and the package version. This way the package isn't mistaken for a different version when the file sizes match (when checksumming isn't used). --- src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1 | 1 + .../helpers/functions/Install-ChocolateyPackage.ps1 | 1 + .../helpers/functions/Install-ChocolateyZipPackage.ps1 | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1 b/src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1 index 8994481dc2..39ee23dbd3 100644 --- a/src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1 +++ b/src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1 @@ -22,6 +22,7 @@ $Note = "Green" $version = $env:packageVersion $packageName = $env:packageName +$packageVersion = $env:packageVersion $packageFolder = $env:packageFolder $helpersPath = (Split-Path -parent $MyInvocation.MyCommand.Definition); diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 index c17fd1ab9a..bdda266f28 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 @@ -85,6 +85,7 @@ param( $chocTempDir = Join-Path $env:TEMP "chocolatey" $tempDir = Join-Path $chocTempDir "$packageName" + if ($env:packageVersion -ne $null) {$tempDir = Join-Path $tempDir "$env:packageVersion"; } if (![System.IO.Directory]::Exists($tempDir)) { [System.IO.Directory]::CreateDirectory($tempDir) | Out-Null } $file = Join-Path $tempDir "$($packageName)Install.$fileType" diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 index 6b7e2caf58..87d3543345 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 @@ -76,6 +76,8 @@ param( $chocTempDir = Join-Path $env:TEMP "chocolatey" $tempDir = Join-Path $chocTempDir "$packageName" + if ($env:packageVersion -ne $null) {$tempDir = Join-Path $tempDir "$env:packageVersion"; } + if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir) | Out-Null} $file = Join-Path $tempDir "$($packageName)Install.$fileType"