Skip to content

Commit

Permalink
(GH-1012) Remove "IsText" File Before Check
Browse files Browse the repository at this point in the history
Ensure that the istext file is not there when we are attempting to
download content any additional times as the new file could have the
correct content type and not be downloading just text.
  • Loading branch information
ferventcoder committed Jan 21, 2017
1 parent d82f23d commit c2b8816
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/chocolatey.resources/helpers/functions/Get-WebFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,15 @@ param(
}
}

$binaryIsTextCheckFile = "$fileName.istext"
if (Test-Path($binaryIsTextCheckFile)) { Remove-Item $binaryIsTextCheckFile -Force -EA SilentlyContinue; }

if ($headers.ContainsKey("Content-Type")) {
$contentType = $headers['Content-Type']
if ($contentType -ne $null) {
if ($contentType.ToLower().Contains("text/html") -or $contentType.ToLower().Contains("text/plain")) {
Write-Warning "$fileName is of content type $contentType"
Set-Content -Path "$fileName.istext" -Value "$fileName has content type $contentType" -Encoding UTF8 -Force
Set-Content -Path $binaryIsTextCheckFile -Value "$fileName has content type $contentType" -Encoding UTF8 -Force
}
}
}
Expand Down

0 comments on commit c2b8816

Please sign in to comment.