diff --git a/src/chocolatey.resources/helpers/functions/Get-FtpFile.ps1 b/src/chocolatey.resources/helpers/functions/Get-FtpFile.ps1 index 9763a47e2b..114362a8a1 100644 --- a/src/chocolatey.resources/helpers/functions/Get-FtpFile.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-FtpFile.ps1 @@ -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 @@ -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) { diff --git a/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 b/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 index 53eb7740eb..7d5e54b9c6 100644 --- a/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 @@ -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); diff --git a/src/chocolatey.resources/helpers/functions/Get-WebFileName.ps1 b/src/chocolatey.resources/helpers/functions/Get-WebFileName.ps1 index 60e4676cf2..450717f3b1 100644 --- a/src/chocolatey.resources/helpers/functions/Get-WebFileName.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-WebFileName.ps1 @@ -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)