Skip to content

Commit

Permalink
(GH-789) Use PowerShell commenting, not C#
Browse files Browse the repository at this point in the history
In Get-FtpFile, Get-WebFile, and Get-WebFileName, a C# comment was used
as a comment in the try catch for determining if it was a local file.
These didn't fail during local testing, but this is now fixed.
  • Loading branch information
ferventcoder committed Jun 12, 2016
1 parent 00e28e5 commit ee1294a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
32 changes: 16 additions & 16 deletions src/chocolatey.resources/helpers/functions/Get-FtpFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,18 @@ param(
return
}

try {
$uri = [System.Uri]$url
if ($uri.IsFile()) {
Write-Debug "Url is local file, setting destination"
if ($url.LocalPath -ne $fileName) {
Copy-Item $uri.LocalPath -Destination $fileName -Force
}
return
}
} catch {
//continue on
try {
$uri = [System.Uri]$url
if ($uri.IsFile()) {
Write-Debug "Url is local file, setting destination"
if ($url.LocalPath -ne $fileName) {
Copy-Item $uri.LocalPath -Destination $fileName -Force
}

return
}
} catch {
#continue on
}

# Create a FTPWebRequest object to handle the connection to the ftp server
Expand Down Expand Up @@ -186,10 +186,10 @@ param(
}

Set-PowerShellExitCode 404
if (env:DownloadCacheAvailable -eq 'true') {
throw "The remote file either doesn't exist, is unauthorized, or is forbidden for url '$url'. $($_.Exception.Message) `nThis package is likely not broken for licensed users - see https://chocolatey.org/docs/features-private-cdn."
} else {
throw "The remote file either doesn't exist, is unauthorized, or is forbidden for url '$url'. $($_.Exception.Message)"
if (env:DownloadCacheAvailable -eq 'true') {
throw "The remote file either doesn't exist, is unauthorized, or is forbidden for url '$url'. $($_.Exception.Message) `nThis package is likely not broken for licensed users - see https://chocolatey.org/docs/features-private-cdn."
} else {
throw "The remote file either doesn't exist, is unauthorized, or is forbidden for url '$url'. $($_.Exception.Message)"
}
} finally {
if ($ftpresponse -ne $null) {
Expand Down
4 changes: 2 additions & 2 deletions src/chocolatey.resources/helpers/functions/Get-WebFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ param(
if ($url.LocalPath -ne $fileName) {
Copy-Item $uri.LocalPath -Destination $fileName -Force
}

return
}
} catch {
//continue on
#continue on
}

$req = [System.Net.HttpWebRequest]::Create($url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ param(
if ($uri.IsFile()) {
$fileName = [System.IO.Path]::GetFileName($uri.LocalPath)
Write-Debug "Url is local file, returning fileName"

return $fileName
}
} catch {
//continue on
#continue on
}

$request = [System.Net.HttpWebRequest]::Create($url)
Expand Down

0 comments on commit ee1294a

Please sign in to comment.